-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
47 lines (44 loc) · 1.04 KB
/
main_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
package main
import "testing"
func TestUpdateContents(t *testing.T) {
img := "snarlysodboxer/my-image"
tag := "1.2.3"
input := `
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-stuff
spec:
template:
spec:
initContainers:
- name: test1
image: snarlysodboxer/my-image:1.19-v0.0.1
- name: test2
image: snarlysodboxer/my-image:0.1.209 # this is a comment that should stay
containers:
- name: test33
image: snarlysodboxer/my-image:7.5.10-v0.0.21`
expected := `
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-stuff
spec:
template:
spec:
initContainers:
- name: test1
image: snarlysodboxer/my-image:1.2.3
- name: test2
image: snarlysodboxer/my-image:1.2.3 # this is a comment that should stay
containers:
- name: test33
image: snarlysodboxer/my-image:1.2.3`
updated := updateContents([]byte(input), &img, &tag)
if string(updated) != expected {
t.Fatalf("Expected: \n%s\nGot: \n%s\n", expected, updated)
}
}