-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes_test.go
73 lines (53 loc) · 1.71 KB
/
types_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package chronos_test
import (
"encoding/json"
"io/ioutil"
"path"
chronos "github.com/axelspringer/go-chronos"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
const FixtureBasePath = "_fixtures"
func getFixtureAsString(f string) string {
p := path.Join(FixtureBasePath, f)
b, err := ioutil.ReadFile(p)
Ω(err).To(BeNil())
return string(b)
}
var _ = Describe("Types", func() {
Describe("Job type serialization/deserialization", func() {
// Based on chronos rest api job example
It("should pass fixture 1 around the world test", func() {
fixData := getFixtureAsString("types_fixture1.json")
Ω(fixData).ShouldNot(BeEmpty())
job := &chronos.Job{}
err := json.Unmarshal([]byte(fixData), job)
Ω(err).Should(BeNil())
b, err := json.Marshal(job)
Ω(err).Should(BeNil())
Ω(string(b)).Should(MatchJSON([]byte(fixData)))
})
// Based on chronos rest api job example
It("should pass fixture 2 around the world test", func() {
fixData := getFixtureAsString("types_fixture2.json")
Ω(fixData).ShouldNot(BeEmpty())
job := &chronos.Job{}
err := json.Unmarshal([]byte(fixData), job)
Ω(err).Should(BeNil())
b, err := json.Marshal(job)
Ω(err).Should(BeNil())
Ω(string(b)).Should(MatchJSON([]byte(fixData)))
})
// This fixture should contain all parameter processed by chronos JobDeserializer
It("should pass fixture 3 around the world test", func() {
fixData := getFixtureAsString("types_fixture3.json")
Ω(fixData).ShouldNot(BeEmpty())
job := &chronos.Job{}
err := json.Unmarshal([]byte(fixData), job)
Ω(err).Should(BeNil())
b, err := json.Marshal(job)
Ω(err).Should(BeNil())
Ω(string(b)).Should(MatchJSON([]byte(fixData)))
})
})
})