forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
120 lines (96 loc) · 2.97 KB
/
config_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package atc_test
import (
. "github.com/concourse/atc"
"gopkg.in/yaml.v2"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Config", func() {
Describe("JobConfig", func() {
Describe("IsSerial", func() {
It("returns true if Serial is true or SerialGroups has items in it", func() {
jobConfig := JobConfig{
Serial: true,
SerialGroups: []string{},
}
Ω(jobConfig.IsSerial()).Should(BeTrue())
jobConfig.SerialGroups = []string{
"one",
}
Ω(jobConfig.IsSerial()).Should(BeTrue())
jobConfig.Serial = false
Ω(jobConfig.IsSerial()).Should(BeTrue())
})
It("returns false if Serial is false and SerialGroups is empty", func() {
jobConfig := JobConfig{
Serial: false,
SerialGroups: []string{},
}
Ω(jobConfig.IsSerial()).Should(BeFalse())
})
})
Describe("GetSerialGroups", func() {
It("Returns the values if SerialGroups is specified", func() {
jobConfig := JobConfig{
SerialGroups: []string{"one", "two"},
}
Ω(jobConfig.GetSerialGroups()).Should(Equal([]string{"one", "two"}))
})
It("Returns the job name if the SerialGroups are not specified", func() {
jobConfig := JobConfig{
Name: "some-job",
Serial: true,
}
Ω(jobConfig.GetSerialGroups()).Should(Equal([]string{"some-job"}))
})
It("returns an empty slice of strings if there are no groups and it is not serial", func() {
jobConfig := JobConfig{
Name: "some-job",
Serial: false,
}
Ω(jobConfig.GetSerialGroups()).Should(Equal([]string{}))
})
})
})
Describe("JobInputConfig", func() {
It("defaults its name to the resource name", func() {
Ω(JobInputConfig{
Resource: "some-resource",
}.Name()).Should(Equal("some-resource"))
Ω(JobInputConfig{
RawName: "some-name",
Resource: "some-resource",
}.Name()).Should(Equal("some-name"))
})
})
Describe("JobOutputConfig", func() {
It("defaults PerformOn to [success]", func() {
Ω(JobOutputConfig{}.PerformOn()).Should(Equal([]Condition{"success"}))
Ω(JobOutputConfig{
RawPerformOn: []Condition{},
}.PerformOn()).Should(Equal([]Condition{}))
Ω(JobOutputConfig{
RawPerformOn: []Condition{"failure"},
}.PerformOn()).Should(Equal([]Condition{"failure"}))
})
})
Describe("Condition", func() {
It("can be unmarshalled from YAML as the string 'success'", func() {
var condition Condition
err := yaml.Unmarshal([]byte("success"), &condition)
Expect(err).ToNot(HaveOccurred())
Expect(condition).To(Equal(ConditionSuccess))
})
It("can be unmarshalled from YAML as the string 'failure'", func() {
var condition Condition
err := yaml.Unmarshal([]byte("failure"), &condition)
Expect(err).ToNot(HaveOccurred())
Expect(condition).To(Equal(ConditionFailure))
})
It("fails to unmarshal other strings", func() {
var condition Condition
err := yaml.Unmarshal([]byte("bogus"), &condition)
Expect(err).To(HaveOccurred())
})
})
})