-
Notifications
You must be signed in to change notification settings - Fork 199
/
suite_data.go
89 lines (73 loc) · 2.72 KB
/
suite_data.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
package suite_init
import (
"os"
"path/filepath"
. "github.com/onsi/gomega"
"github.com/werf/werf/test/pkg/utils"
)
type SuiteData struct {
*StubsData
*SynchronizedSuiteCallbacksData
*WerfBinaryData
*ProjectNameData
*K8sDockerRegistryData
*TmpDirData
*ContainerRegistryPerImplementationData
}
func (data *SuiteData) SetupStubs(setupData *StubsData) bool {
data.StubsData = setupData
return true
}
func (data *SuiteData) SetupSynchronizedSuiteCallbacks(setupData *SynchronizedSuiteCallbacksData) bool {
data.SynchronizedSuiteCallbacksData = setupData
return true
}
func (data *SuiteData) SetupWerfBinary(setupData *WerfBinaryData) bool {
data.WerfBinaryData = setupData
return true
}
func (data *SuiteData) SetupProjectName(setupData *ProjectNameData) bool {
data.ProjectNameData = setupData
return true
}
func (data *SuiteData) SetupK8sDockerRegistry(setupData *K8sDockerRegistryData) bool {
data.K8sDockerRegistryData = setupData
return true
}
func (data *SuiteData) SetupTmp(setupData *TmpDirData) bool {
data.TmpDirData = setupData
return true
}
func (data *SuiteData) SetupContainerRegistryPerImplementation(setupData *ContainerRegistryPerImplementationData) bool {
data.ContainerRegistryPerImplementationData = setupData
return true
}
func (data *SuiteData) GetTestRepoPath(dirname string) string {
testReposDir := filepath.Join(data.TestDirPath, "repos")
Expect(os.MkdirAll(testReposDir, os.ModePerm)).To(Succeed())
return filepath.Join(testReposDir, dirname)
}
func (data *SuiteData) GetBuildReportPath(filename string) string {
buildReportsDir := filepath.Join(data.TestDirPath, "build-reports")
Expect(os.MkdirAll(buildReportsDir, os.ModePerm)).To(Succeed())
return filepath.Join(buildReportsDir, filename)
}
func (data *SuiteData) GetDeployReportPath(filename string) string {
deployReportsDir := filepath.Join(data.TestDirPath, "deploy-reports")
Expect(os.MkdirAll(deployReportsDir, os.ModePerm)).To(Succeed())
return filepath.Join(deployReportsDir, filename)
}
func (data *SuiteData) InitTestRepo(dirname, fixtureRelPath string) {
testRepoPath := data.GetTestRepoPath(dirname)
utils.CopyIn(utils.FixturePath(fixtureRelPath), testRepoPath)
utils.RunSucceedCommand(testRepoPath, "git", "init")
utils.RunSucceedCommand(testRepoPath, "git", "add", ".")
utils.RunSucceedCommand(testRepoPath, "git", "commit", "-m", "initial")
}
func (data *SuiteData) UpdateTestRepo(dirname, fixtureRelPath string) {
testRepoPath := data.GetTestRepoPath(dirname)
utils.RunSucceedCommand(testRepoPath, "git", "rm", "--ignore-unmatch", "-rf", ".")
utils.CopyIn(utils.FixturePath(fixtureRelPath), testRepoPath)
utils.RunSucceedCommand(testRepoPath, "git", "add", ".")
utils.RunSucceedCommand(testRepoPath, "git", "commit", "-m", "updated")
}