-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder_test.go
52 lines (43 loc) · 1.04 KB
/
builder_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
package main
import (
"fmt"
)
type TestDockerfile struct {
Dockerfile
Stream string
}
func (d TestDockerfile) ReadPrelude() string {
return "testing prelude"
}
func (d TestDockerfile) ReadBase() string {
return "testing base"
}
func (d TestDockerfile) ReadExtras(packageName string) string {
if(packageName == "test1") {
return "install test1"
} else if(packageName == "test2") {
return "install test2"
} else {
return fmt.Sprint("install", packageName)
}
}
func (d TestDockerfile) ReadEpilogue(packages []string) string {
return "testing epilogue"
}
func (d *TestDockerfile) Write(template string) (ret int, err error) {
d.bytes = []byte(template)
// in prod code write straight to S3
return len(d.bytes), nil
}
func ExampleWrite() {
b := new(TestDockerfile)
fmt.Println(b.Contents()) // Ensures b.Contents() is empty
MakeDockerfile([]string{"test1", "test2"}, b)
fmt.Println(b.Contents())
// Output:
// testing prelude
// testing base
// install test1
// install test2
// testing epilogue
}