Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Sep 21, 2023
1 parent e0210fa commit 7d52cf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions jutils/jutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
}
})
}
}
Expand Down Expand Up @@ -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{})
}

Expand Down
2 changes: 1 addition & 1 deletion jutils/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 7d52cf2

Please sign in to comment.