forked from jfrog/jfrog-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifactorybulkrepository_test.go
More file actions
174 lines (130 loc) · 6.92 KB
/
artifactorybulkrepository_test.go
File metadata and controls
174 lines (130 loc) · 6.92 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package main
import (
"fmt"
"testing"
"github.com/jfrog/jfrog-cli/utils/tests"
"github.com/stretchr/testify/assert"
)
func TestRepositoryCreateAndUpdateIntegration(t *testing.T) {
initArtifactoryTest(t, "")
defer cleanArtifactoryTest()
t.Run("SingleRepositoryCreate", func(t *testing.T) {
testSingleRepositoryCreate(t)
})
t.Run("SingleRepositoryUpdate", func(t *testing.T) {
testSingleRepositoryUpdate(t)
})
t.Run("MultipleRepositoryCreate", func(t *testing.T) {
testMultipleRepositoryCreate(t)
})
t.Run("MultipleRepositoryUpdate", func(t *testing.T) {
testMultipleRepositoryUpdate(t)
})
t.Run("DifferentPackageTypesAndRClass", func(t *testing.T) {
testCreateWithDifferentRclass(t)
})
t.Run("DifferentPackageTypesAndRClassUpdate", func(t *testing.T) {
testUpdateWithDifferentRclass(t)
})
}
func testSingleRepositoryCreate(t *testing.T) {
templatePath := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
runRt(t, "repo-create", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))
assert.True(t, isRepoExist(tests.MvnRepo1), "Repository should exist after creation")
execDeleteRepo(tests.MvnRepo1)
}
func testSingleRepositoryUpdate(t *testing.T) {
templatePath := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
runRt(t, "repo-create", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))
runRt(t, "repo-update", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))
assert.True(t, isRepoExist(tests.MvnRepo1), "Repository should still exist after update")
execDeleteRepo(tests.MvnRepo1)
}
func testMultipleRepositoryCreate(t *testing.T) {
repo1Name := "test-maven-repo1"
repo2Name := "test-npm-repo2"
repo3Name := "test-docker-repo3"
templatePath := tests.GetTestResourcesPath() + tests.MultipleRepositoriesConfig
runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))
assert.True(t, isRepoExist(repo1Name), "Repository 1 doesn't exist")
assert.True(t, isRepoExist(repo2Name), "Repository 2 doesn't exist")
assert.True(t, isRepoExist(repo3Name), "Repository 3 doesn't exist")
execDeleteRepo(repo1Name)
execDeleteRepo(repo2Name)
execDeleteRepo(repo3Name)
}
func testMultipleRepositoryUpdate(t *testing.T) {
repo1Name := "test-multi-repo1"
repo2Name := "test-multi-repo2"
repo3Name := "test-multi-repo3"
templatePath := tests.GetTestResourcesPath() + tests.MultipleRepositoriesConfig
runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))
runRt(t, "repo-update", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))
assert.True(t, isRepoExist(repo1Name), "Repository 1 doesn't exist")
assert.True(t, isRepoExist(repo2Name), "Repository 2 doesn't exist")
assert.True(t, isRepoExist(repo3Name), "Repository 3 doesn't exist")
execDeleteRepo(repo1Name)
execDeleteRepo(repo2Name)
execDeleteRepo(repo3Name)
}
func testCreateWithDifferentRclass(t *testing.T) {
t.Skip("RTECO-525 - Skipping testCreateWithDifferentRclass")
mvnRepoName := "test-mvn-local1"
dockerLocalRepoName := "test-docker-local1"
npmRepoName := "test-npm-local"
dockerRemoteRepoName := "test-docker-remote1"
dockerVirtualRepoName := "test-docker-virtual1"
templatePathForLocalMvnRepo := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
templatePathForDockerRepo := tests.GetTestResourcesPath() + tests.DockerLocalRepositoryConfig
runRt(t, "repo-create", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-create", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))
templatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesConfig
runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))
assert.True(t, isRepoExist(mvnRepoName), "local Maven repository doesn't exist")
assert.True(t, isRepoExist(dockerLocalRepoName), "local docker repository doesn't exist")
assert.True(t, isRepoExist(npmRepoName), "local npm repository doesn't exist")
assert.True(t, isRepoExist(dockerRemoteRepoName), "remote docker repository doesn't exist")
assert.True(t, isRepoExist(dockerVirtualRepoName), "virtual docker repository doesn't exist")
execDeleteRepo(dockerVirtualRepoName)
execDeleteRepo(dockerRemoteRepoName)
execDeleteRepo(npmRepoName)
execDeleteRepo(dockerLocalRepoName)
execDeleteRepo(mvnRepoName)
}
func testUpdateWithDifferentRclass(t *testing.T) {
t.Skip("RTECO-525 - Skipping testUpdateWithDifferentRclass")
mvnRepoName := "test-mvn-local-1"
dockerLocalRepoName := "test-docker-local-1"
npmRepoName := "test-npm-local"
dockerRemoteRepoName := "test-docker-remote-1"
dockerVirtualRepoName := "test-docker-virtual-1"
templatePathForLocalMvnRepo := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
templatePathForDockerRepo := tests.GetTestResourcesPath() + tests.DockerLocalRepositoryConfig
runRt(t, "repo-create", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-create", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))
createTemplatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesConfig
runRt(t, "repo-create", createTemplatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))
updateTemplatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesUpdateConfig
runRt(t, "repo-update", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-update", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))
runRt(t, "repo-update", updateTemplatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))
assert.True(t, isRepoExist(mvnRepoName), "local Maven repository doesn't exist after update")
assert.True(t, isRepoExist(dockerLocalRepoName), "local docker repository doesn't exist after update")
assert.True(t, isRepoExist(npmRepoName), "local npm repository doesn't exist after update")
assert.True(t, isRepoExist(dockerRemoteRepoName), "remote docker repository doesn't exist after update")
assert.True(t, isRepoExist(dockerVirtualRepoName), "virtual docker repository doesn't exist after update")
execDeleteRepo(dockerVirtualRepoName)
execDeleteRepo(dockerRemoteRepoName)
execDeleteRepo(npmRepoName)
execDeleteRepo(dockerLocalRepoName)
execDeleteRepo(mvnRepoName)
}