-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtemplate_test.go
More file actions
55 lines (46 loc) · 1.12 KB
/
template_test.go
File metadata and controls
55 lines (46 loc) · 1.12 KB
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
package template_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"io"
"os"
"testing"
)
var tmpDir *string
const serviceConfigFile = "stack_test.yaml"
func TestTemplate(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Component Configuration Test Suite")
}
var _ = BeforeSuite(func() {
var err error
tmpDir = new(string)
*tmpDir, err = os.MkdirTemp("", "o2control-local-service")
Expect(err).NotTo(HaveOccurred())
// copy config files
configFiles := []string{serviceConfigFile}
for _, configFile := range configFiles {
from, err := os.Open("./" + configFile)
Expect(err).NotTo(HaveOccurred())
defer func() {
err := from.Close()
if err != nil {
Expect(err).NotTo(HaveOccurred())
}
}()
to, err := os.OpenFile(*tmpDir+"/"+configFile, os.O_RDWR|os.O_CREATE, 0666)
Expect(err).NotTo(HaveOccurred())
defer func() {
err := to.Close()
if err != nil {
Expect(err).NotTo(HaveOccurred())
}
}()
_, err = io.Copy(to, from)
Expect(err).NotTo(HaveOccurred())
}
})
var _ = AfterSuite(func() {
err := os.RemoveAll(*tmpDir)
Expect(err).NotTo(HaveOccurred())
})