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