@@ -22,19 +22,19 @@ const (
2222 staging = "https://example.com/testing/staging-env"
2323)
2424
25- func TestPromoteWithSuccessKeepCacheTrue (t * testing.T ) {
26- promoteWithSuccess (t , true , "" )
25+ func TestPromoteWithSuccessKeepCacheTrueWithGHE (t * testing.T ) {
26+ promoteWithSuccess (t , true , "ghe" , true , " " )
2727}
2828
29- func TestPromoteWithSuccessKeepCacheFalse (t * testing.T ) {
30- promoteWithSuccess (t , false , "" )
29+ func TestPromoteWithSuccessKeepCacheFalseWithGitHub (t * testing.T ) {
30+ promoteWithSuccess (t , false , "github" , false , " " )
3131}
3232
3333func TestPromoteWithSuccessCustomMsg (t * testing.T ) {
3434 promoteLocalWithSuccess (t , true , "custom commit message here" )
3535}
3636
37- func promoteWithSuccess (t * testing.T , keepCache bool , msg string ) {
37+ func promoteWithSuccess (t * testing.T , keepCache bool , repoType string , tlsVerify bool , msg string ) {
3838 dstBranch := "test-branch"
3939 author := & git.
Author {
Name :
"Testing User" ,
Email :
"[email protected] " ,
Token :
"test-token" }
4040 devRepo , stagingRepo := mock .New ("/dev" , "master" ), mock .New ("/staging" , "master" )
@@ -43,11 +43,22 @@ func promoteWithSuccess(t *testing.T, keepCache bool, msg string) {
4343 mustAddCredentials (t , staging , author ): stagingRepo ,
4444 }
4545 sm := New ("tmp" , author )
46- sm .clientFactory = func (s string ) * scm.Client {
46+ sm .repoType = repoType
47+ sm .tlsVerify = tlsVerify
48+ sm .clientFactory = func (s , ty , r string , v bool ) * scm.Client {
4749 client , _ := fakescm .NewDefault ()
50+ if r != repoType {
51+ t .Fatalf ("repoType doesn't match %s != %s\n " , r , repoType )
52+ }
53+ if v != tlsVerify {
54+ t .Fatalf ("tlsVerify doesn't match in ClientFactory %v != %v\n " , v , tlsVerify )
55+ }
4856 return client
4957 }
50- sm .repoFactory = func (url , _ string , _ bool ) (git.Repo , error ) {
58+ sm .repoFactory = func (url , _ string , v bool , _ bool ) (git.Repo , error ) {
59+ if v != tlsVerify {
60+ t .Fatalf ("tlsVerify doesn't match in RepoFactory %v != %v\n " , v , tlsVerify )
61+ }
5162 return git .Repo (repos [url ]), nil
5263 }
5364 devRepo .AddFiles ("/services/my-service/base/config/myfile.yaml" )
@@ -96,11 +107,11 @@ func promoteLocalWithSuccess(t *testing.T, keepCache bool, msg string) {
96107 devRepo := NewLocal ("/dev" )
97108
98109 sm := New ("tmp" , author )
99- sm .clientFactory = func (s string ) * scm.Client {
110+ sm .clientFactory = func (s , t , r string , v bool ) * scm.Client {
100111 client , _ := fakescm .NewDefault ()
101112 return client
102113 }
103- sm .repoFactory = func (url , _ string , _ bool ) (git.Repo , error ) {
114+ sm .repoFactory = func (url , _ string , _ bool , _ bool ) (git.Repo , error ) {
104115 return git .Repo (stagingRepo ), nil
105116 }
106117 sm .localFactory = func (path string , _ bool ) git.Source {
@@ -173,11 +184,11 @@ func TestPromoteWithCacheDeletionFailure(t *testing.T) {
173184 mustAddCredentials (t , staging , author ): stagingRepo ,
174185 }
175186 sm := New ("tmp" , author )
176- sm .clientFactory = func (s string ) * scm.Client {
187+ sm .clientFactory = func (s , t , r string , v bool ) * scm.Client {
177188 client , _ := fakescm .NewDefault ()
178189 return client
179190 }
180- sm .repoFactory = func (url , _ string , _ bool ) (git.Repo , error ) {
191+ sm .repoFactory = func (url , _ string , _ bool , _ bool ) (git.Repo , error ) {
181192 return git .Repo (repos [url ]), nil
182193 }
183194 devRepo .AddFiles ("/services/my-service/base/config/myfile.yaml" )
@@ -287,13 +298,13 @@ func TestRepositoryCloneErrorOmitsToken(t *testing.T) {
287298 dstBranch := "test-branch"
288299 author := & git.
Author {
Name :
"Testing User" ,
Email :
"[email protected] " ,
Token :
"test-token" }
289300 client , _ := fakescm .NewDefault ()
290- fakeClientFactory := func (s string ) * scm.Client {
301+ fakeClientFactory := func (s , t , r string , v bool ) * scm.Client {
291302 return client
292303 }
293304 sm := New ("tmp" , author )
294305 sm .clientFactory = fakeClientFactory
295306
296- sm .repoFactory = func (url , _ string , _ bool ) (git.Repo , error ) {
307+ sm .repoFactory = func (url , _ string , _ bool , _ bool ) (git.Repo , error ) {
297308 // This actually causes the error and results in trying to create a repository
298309 // which can surface the token
299310 errorMessage := fmt .Errorf ("failed to clone repository %s: exit status 128" , dev )
0 commit comments