Skip to content

Commit 6726b05

Browse files
committed
Fix validation tests to not include GitHub projects
Signed-off-by: Angel Misevski <[email protected]>
1 parent 18525d4 commit 6726b05

File tree

3 files changed

+11
-48
lines changed

3 files changed

+11
-48
lines changed

Diff for: pkg/validation/projects.go

-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ func ValidateStarterProjects(starterProjects []v1alpha2.StarterProject) error {
1515
var gitSource v1alpha2.GitLikeProjectSource
1616
if starterProject.Git != nil {
1717
gitSource = starterProject.Git.GitLikeProjectSource
18-
} else if starterProject.Github != nil {
19-
gitSource = starterProject.Github.GitLikeProjectSource
2018
} else {
2119
continue
2220
}
@@ -53,8 +51,6 @@ func ValidateProjects(projects []v1alpha2.Project) error {
5351
var gitSource v1alpha2.GitLikeProjectSource
5452
if project.Git != nil {
5553
gitSource = project.Git.GitLikeProjectSource
56-
} else if project.Github != nil {
57-
gitSource = project.Github.GitLikeProjectSource
5854
} else {
5955
continue
6056
}

Diff for: pkg/validation/projects_test.go

+9-37
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ func generateDummyGitStarterProject(name string, checkoutRemote *v1alpha2.Checko
2121
}
2222
}
2323

24-
func generateDummyGithubStarterProject(name string, checkoutRemote *v1alpha2.CheckoutFrom, remotes map[string]string) v1alpha2.StarterProject {
25-
return v1alpha2.StarterProject{
26-
Name: name,
27-
ProjectSource: v1alpha2.ProjectSource{
28-
Github: &v1alpha2.GithubProjectSource{
29-
GitLikeProjectSource: v1alpha2.GitLikeProjectSource{
30-
Remotes: remotes,
31-
CheckoutFrom: checkoutRemote,
32-
},
33-
},
34-
},
35-
}
36-
}
37-
3824
func generateDummyGitProject(name string, checkoutRemote *v1alpha2.CheckoutFrom, remotes map[string]string) v1alpha2.Project {
3925
return v1alpha2.Project{
4026
Name: name,
@@ -49,20 +35,6 @@ func generateDummyGitProject(name string, checkoutRemote *v1alpha2.CheckoutFrom,
4935
}
5036
}
5137

52-
func generateDummyGithubProject(name string, checkoutRemote *v1alpha2.CheckoutFrom, remotes map[string]string) v1alpha2.Project {
53-
return v1alpha2.Project{
54-
Name: name,
55-
ProjectSource: v1alpha2.ProjectSource{
56-
Github: &v1alpha2.GithubProjectSource{
57-
GitLikeProjectSource: v1alpha2.GitLikeProjectSource{
58-
Remotes: remotes,
59-
CheckoutFrom: checkoutRemote,
60-
},
61-
},
62-
},
63-
}
64-
}
65-
6638
func TestValidateStarterProjects(t *testing.T) {
6739

6840
oneRemoteErr := "starterProject .* should have one remote only"
@@ -84,14 +56,14 @@ func TestValidateStarterProjects(t *testing.T) {
8456
{
8557
name: "Invalid Starter Project",
8658
starterProjects: []v1alpha2.StarterProject{
87-
generateDummyGithubStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote", "test": "testremote"}),
59+
generateDummyGitStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote", "test": "testremote"}),
8860
},
8961
wantErr: &oneRemoteErr,
9062
},
9163
{
9264
name: "Invalid Starter Project with wrong checkout",
9365
starterProjects: []v1alpha2.StarterProject{
94-
generateDummyGithubStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"test": "testremote"}),
66+
generateDummyGitStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"test": "testremote"}),
9567
},
9668
wantErr: &wrongCheckoutErr,
9769
},
@@ -110,8 +82,8 @@ func TestValidateStarterProjects(t *testing.T) {
11082
{
11183
name: "Invalid Starter Project with empty remotes",
11284
starterProjects: []v1alpha2.StarterProject{
113-
generateDummyGithubStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{}),
114-
generateDummyGithubStarterProject("project3", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote", "test": "testremote"}),
85+
generateDummyGitStarterProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{}),
86+
generateDummyGitStarterProject("project3", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote", "test": "testremote"}),
11587
},
11688
wantErr: &atleastOneRemoteErr,
11789
},
@@ -144,28 +116,28 @@ func TestValidateProjects(t *testing.T) {
144116
name: "Valid Project",
145117
projects: []v1alpha2.Project{
146118
generateDummyGitProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote"}),
147-
generateDummyGithubProject("project2", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote"}),
119+
generateDummyGitProject("project2", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote"}),
148120
},
149121
},
150122
{
151123
name: "Invalid Project with multiple remotes but no checkoutfrom",
152124
projects: []v1alpha2.Project{
153-
generateDummyGithubProject("project2", nil, map[string]string{"origin": "originremote", "test": "testremote"}),
125+
generateDummyGitProject("project2", nil, map[string]string{"origin": "originremote", "test": "testremote"}),
154126
},
155127
wantErr: &missingCheckOutFromRemoteErr,
156128
},
157129
{
158130
name: "Invalid Project with multiple remote and empty checkout remote",
159131
projects: []v1alpha2.Project{
160132
generateDummyGitProject("project2", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{"origin": "originremote"}),
161-
generateDummyGithubProject("project1", &v1alpha2.CheckoutFrom{Remote: ""}, map[string]string{"origin": "originremote", "test": "testremote"}),
133+
generateDummyGitProject("project1", &v1alpha2.CheckoutFrom{Remote: ""}, map[string]string{"origin": "originremote", "test": "testremote"}),
162134
},
163135
wantErr: &missingCheckOutFromRemoteErr,
164136
},
165137
{
166138
name: "Invalid Project with wrong checkout",
167139
projects: []v1alpha2.Project{
168-
generateDummyGithubProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin1"}, map[string]string{"origin": "originremote", "test": "testremote"}),
140+
generateDummyGitProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin1"}, map[string]string{"origin": "originremote", "test": "testremote"}),
169141
generateDummyGitProject("project2", &v1alpha2.CheckoutFrom{Remote: "origin1"}, map[string]string{"origin2": "originremote2"}),
170142
},
171143
wantErr: &wrongCheckoutErr,
@@ -180,7 +152,7 @@ func TestValidateProjects(t *testing.T) {
180152
name: "Invalid Project with empty remotes",
181153
projects: []v1alpha2.Project{
182154
generateDummyGitProject("project1", &v1alpha2.CheckoutFrom{Remote: "origin"}, map[string]string{}),
183-
generateDummyGithubProject("project2", &v1alpha2.CheckoutFrom{Remote: "origins"}, map[string]string{"origin": "originremote", "test": "testremote"}),
155+
generateDummyGitProject("project2", &v1alpha2.CheckoutFrom{Remote: "origins"}, map[string]string{"origin": "originremote", "test": "testremote"}),
184156
},
185157
wantErr: &atleastOneRemoteErr,
186158
},

Diff for: pkg/validation/variables/variables_project.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,8 @@ func validateandReplaceForProjectSource(variables map[string]string, projectSour
8989
if projectSource.Zip.Location, err = validateAndReplaceDataWithVariable(projectSource.Zip.Location, variables); err != nil {
9090
checkForInvalidError(invalidKeys, err)
9191
}
92-
case projectSource.Git != nil || projectSource.Github != nil:
93-
var gitProject *v1alpha2.GitLikeProjectSource
94-
if projectSource.Git != nil {
95-
gitProject = &projectSource.Git.GitLikeProjectSource
96-
} else if projectSource.Github != nil {
97-
gitProject = &projectSource.Github.GitLikeProjectSource
98-
}
92+
case projectSource.Git != nil:
93+
gitProject := &projectSource.Git.GitLikeProjectSource
9994

10095
if gitProject.CheckoutFrom != nil {
10196
// validate git checkout revision

0 commit comments

Comments
 (0)