(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestStringToTimeHookFunc(t *testing.T) { |
| 275 | strValue := reflect.ValueOf("5") |
| 276 | timeValue := reflect.ValueOf(time.Time{}) |
| 277 | cases := []struct { |
| 278 | f, t reflect.Value |
| 279 | layout string |
| 280 | result interface{} |
| 281 | err bool |
| 282 | }{ |
| 283 | {reflect.ValueOf("2006-01-02T15:04:05Z"), timeValue, time.RFC3339, |
| 284 | time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), false}, |
| 285 | {strValue, timeValue, time.RFC3339, time.Time{}, true}, |
| 286 | {strValue, strValue, time.RFC3339, "5", false}, |
| 287 | } |
| 288 | |
| 289 | for i, tc := range cases { |
| 290 | f := StringToTimeHookFunc(tc.layout) |
| 291 | actual, err := DecodeHookExec(f, tc.f, tc.t) |
| 292 | if tc.err != (err != nil) { |
| 293 | t.Fatalf("case %d: expected err %#v", i, tc.err) |
| 294 | } |
| 295 | if !reflect.DeepEqual(actual, tc.result) { |
| 296 | t.Fatalf( |
| 297 | "case %d: expected %#v, got %#v", |
| 298 | i, tc.result, actual) |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | func TestStringToIPHookFunc(t *testing.T) { |
| 304 | strValue := reflect.ValueOf("5") |
nothing calls this directly
no test coverage detected
searching dependent graphs…