-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: timestamp length only for valid timestamps (#5819)
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package testworkflows | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetetTimestampLength(t *testing.T) { | ||
t.Run("returns length of nano for valid timestamps", func(t *testing.T) { | ||
l := getTimestampLength("2006-01-02T15:04:05.999999999Z07:00") | ||
assert.Equal(t, len(time.RFC3339Nano), l) | ||
|
||
l = getTimestampLength("2006-01-02T15:04:05.999999999+07:00") | ||
assert.Equal(t, len(time.RFC3339Nano), l) | ||
}) | ||
|
||
t.Run("returns 0 for invalid timestamps", func(t *testing.T) { | ||
l := getTimestampLength("2006-01-02T15:04:05.99") | ||
assert.Equal(t, 0, l) | ||
|
||
l = getTimestampLength("2006-01-02T15:04:05.99") | ||
assert.Equal(t, 0, l) | ||
}) | ||
} |