MCPcopy Create free account
hub / github.com/abice/go-enum / TestSQLStrIntExtras

Function TestSQLStrIntExtras

example/sql_str_int_enum_test.go:324–429  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

322}
323
324func TestSQLStrIntExtras(t *testing.T) {
325 assert.Equal(t, sqlIntGreekGodMap[20], GreekGod("athena"), "String value is not correct")
326
327 _, err := ParseGreekGod(`NotAStatus`)
328 assert.Error(t, err, "Should have had an error parsing a non god")
329 assert.True(t, errors.Is(err, ErrInvalidGreekGod))
330
331 var (
332 intVal int = 3
333 strVal string = "completed"
334 enumVal JobState = JobStateCompleted
335 nullInt *int
336 nullInt64 *int64
337 nullUint *uint
338 nullUint64 *uint64
339 nullString *string
340 nullJobState *JobState
341 )
342
343 tests := map[string]struct {
344 input interface{}
345 result NullJobState
346 }{
347 "nil": {},
348 "val": {
349 input: JobStateFailed,
350 result: NullJobState{
351 JobState: JobStateFailed,
352 Valid: true,
353 },
354 },
355 "ptr": {
356 input: &enumVal,
357 result: NullJobState{
358 JobState: JobStateCompleted,
359 Valid: true,
360 },
361 },
362 "string": {
363 input: strVal,
364 result: NullJobState{
365 JobState: JobStateCompleted,
366 Valid: true,
367 },
368 },
369 "*string": {
370 input: &strVal,
371 result: NullJobState{
372 JobState: JobStateCompleted,
373 Valid: true,
374 },
375 },
376 "invalid string": {
377 input: "random value",
378 },
379 "[]byte": {
380 input: []byte(JobStateProcessing.String()),
381 result: NullJobState{

Callers

nothing calls this directly

Calls 4

GreekGodTypeAlias · 0.85
ParseGreekGodFunction · 0.85
NewNullJobStateFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…