-
Notifications
You must be signed in to change notification settings - Fork 0
/
status_test.go
42 lines (33 loc) · 1.06 KB
/
status_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package jobs
import (
"encoding/json"
"testing"
"github.com/cheekybits/is"
)
func TestStatus(t *testing.T) {
is := is.New(t)
is.Equal(StatusNew.String(), "new")
is.Equal(StatusFailed.String(), "failed")
is.Equal(StatusSuccess.String(), "success")
is.Equal(StatusWaiting.String(), "waiting")
is.Equal(StatusWorking.String(), "working")
is.Equal(StatusInvalid, parseStatus("bollocks"))
is.Equal(StatusNew, parseStatus("new"))
is.Equal(StatusSuccess, parseStatus("success"))
is.Equal(StatusFailed, parseStatus("failed"))
is.Equal(StatusWaiting, parseStatus("waiting"))
is.Equal(StatusWorking, parseStatus("working"))
b, err := json.Marshal(StatusNew)
is.NoErr(err)
is.Equal(string(b), `"new"`)
// var s Status
// is.NoErr(json.Unmarshal([]byte(`"success"`), &s))
// is.Equal(s, StatusSuccess)
// obj := bson.M{"status": StatusWaiting}
// b, err = bson.Marshal(obj)
// is.NoErr(err)
// is.Equal(true, bytes.Contains(b, []byte(StatusWaiting.String())))
// var obj2 bson.M
// is.NoErr(bson.Unmarshal(b, &obj2))
// is.Equal(obj2["status"], StatusWaiting)
}