Skip to content

Commit

Permalink
add JSONTime test
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Aug 31, 2022
1 parent 0b2c5fa commit e47ef98
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions info_test.go
@@ -0,0 +1,44 @@
package slack

import (
"testing"
)

func TestJSONTime_UnmarshalJSON(t *testing.T) {
type args struct {
buf []byte
}
tests := []struct {
name string
args args
wantTr JSONTime
wantErr bool
}{
{
"acceptable int64 timestamp",
args{[]byte(`1643435556`)},
JSONTime(1643435556),
false,
},
{
"acceptable string timestamp",
args{[]byte(`"1643435556"`)},
JSONTime(1643435556),
false,
},
{
"null",
args{[]byte(`null`)},
JSONTime(0),
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var tr JSONTime
if err := tr.UnmarshalJSON(tt.args.buf); (err != nil) != tt.wantErr {
t.Errorf("JSONTime.UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

0 comments on commit e47ef98

Please sign in to comment.