diff --git a/jutils/jutils_test.go b/jutils/jutils_test.go index 0ae9282..6628306 100644 --- a/jutils/jutils_test.go +++ b/jutils/jutils_test.go @@ -57,22 +57,27 @@ func TestLoadEnvVarOrPanic(t *testing.T) { t.Setenv("MOCK_ENV_VAR", "lupulella-2") tt := []struct { - name string - varId string + name string + varId string + shouldPanic bool }{ { - name: "env var exists", - varId: "MOCK_ENV_VAR", + name: "env var exists", + varId: "MOCK_ENV_VAR", + shouldPanic: false, }, { - name: "env var doesn't exist", - varId: "I_DONT_EXIST", + name: "env var doesn't exist", + varId: "I_DONT_EXIST", + shouldPanic: true, }, } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { fmt.Println(tc.varId) - shouldPanic(t, func() { LoadEnvVarOrPanic(tc.varId) }) + if tc.shouldPanic { + shouldPanic(t, func() { LoadEnvVarOrPanic(tc.varId) }) + } }) } } @@ -101,7 +106,7 @@ func TestFriendlyTimestamp(t *testing.T) { if err != nil { t.Error(err) } - r.IsType(now, reflect.TypeOf("")) + r.IsType(now, "") r.IsType(parsedTime, time.Time{}) } diff --git a/jutils/time.go b/jutils/time.go index 4efda16..3b6dc5b 100644 --- a/jutils/time.go +++ b/jutils/time.go @@ -7,7 +7,7 @@ import ( func FriendlyTimestamp() string { currentTime := time.Now() - return fmt.Sprintf("%d-%d-%d %d:%d:%d", + return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d", currentTime.Year(), currentTime.Month(), currentTime.Day(),