MCPcopy Create free account
hub / github.com/quay/clair / TestTimeNotNull

Function TestTimeNotNull

internal/codec/codec_test.go:78–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestTimeNotNull(t *testing.T) {
79 type s struct {
80 Time time.Time
81 }
82 var b bytes.Buffer
83 enc := GetEncoder(&b)
84 defer PutEncoder(enc)
85
86 // Example encoding of a populated time:
87 if err := enc.Encode(s{Time: time.Unix(0, 0).UTC()}); err != nil {
88 t.Error(err)
89 }
90 t.Log(b.String())
91 b.Reset()
92
93 // Now encode a zero time and make sure it's a string.
94 if err := enc.Encode(s{}); err != nil {
95 t.Error(err)
96 }
97 t.Log(b.String())
98 if strings.Contains(b.String(), "null") {
99 t.Error("wanted non-null encoding")
100 }
101}

Callers

nothing calls this directly

Calls 5

GetEncoderFunction · 0.85
PutEncoderFunction · 0.85
ResetMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected