-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_test.go
60 lines (48 loc) · 1.51 KB
/
release_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
package manifest
import (
"testing"
"github.com/stretchr/testify/assert"
yaml "gopkg.in/yaml.v2"
)
func TestUnmarshalRelease(t *testing.T) {
t.Run("ReturnsUnmarshaledRelease", func(t *testing.T) {
var release EstafetteRelease
// act
err := yaml.Unmarshal([]byte(`
stages:
deploy:
image: extensions/deploy-to-kubernetes-engine:stable
create-release-notes:
image: extensions/create-release-notes-from-changelog:stable
`), &release)
assert.Nil(t, err)
assert.Equal(t, 2, len(release.Stages))
assert.Equal(t, "deploy", release.Stages[0].Name)
assert.Equal(t, "extensions/deploy-to-kubernetes-engine:stable", release.Stages[0].ContainerImage)
assert.Equal(t, "create-release-notes", release.Stages[1].Name)
assert.Equal(t, "extensions/create-release-notes-from-changelog:stable", release.Stages[1].ContainerImage)
})
}
func TestReleaseToYamlMarshalling(t *testing.T) {
t.Run("UnmarshallingThenMarshallingReturnsTheSameFile", func(t *testing.T) {
var release EstafetteRelease
input := `stages:
deploy:
image: extensions/deploy-to-kubernetes-engine:stable
shell: /bin/sh
workDir: /estafette-work
when: status == 'succeeded'
create-release-notes:
image: extensions/create-release-notes-from-changelog:stable
shell: /bin/sh
workDir: /estafette-work
when: status == 'succeeded'
`
err := yaml.Unmarshal([]byte(input), &release)
assert.Nil(t, err)
// act
output, err := yaml.Marshal(release)
assert.Nil(t, err)
assert.Equal(t, input, string(output))
})
}