MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestDateTime

Function TestDateTime

env/types_test.go:605–635  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

603}
604
605func TestDateTime(t *testing.T) {
606 tests := []struct {
607 input string
608 want time.Time
609 wantErr bool
610 }{
611 {input: "", want: time.Time{}},
612 {
613 input: "2006-01-02T15:04:05Z",
614 want: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
615 },
616 {input: "invalid-date", wantErr: true},
617 }
618
619 for _, tt := range tests {
620 t.Run(tt.input+"=>"+tt.want.String(), func(t *testing.T) {
621 t.Setenv(testVar, tt.input)
622 desc := env.DateTime(testVar)
623
624 var result time.Time
625 err := desc.Parse(&result)
626
627 if tt.wantErr {
628 require.Error(t, err)
629 } else {
630 require.NoError(t, err)
631 assert.Equal(t, tt.want, result)
632 }
633 })
634 }
635}
636
637func TestRegexpFromPattern(t *testing.T) {
638 tests := []struct {

Callers

nothing calls this directly

Calls 5

DateTimeFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected