@@ -93,10 +93,16 @@ func TestMemcached(t *testing.T) {
93
93
ctx .AddCleanupFn (func () error { return os .RemoveAll (absProjectPath ) })
94
94
95
95
os .Chdir ("memcached-operator" )
96
- prSlug , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
97
- if ok && prSlug != "" {
98
- prSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
99
- if ok && prSha != "" {
96
+ repo , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
97
+ if repo == "" {
98
+ repo , ok = os .LookupEnv ("TRAVIS_REPO_SLUG" )
99
+ }
100
+ if ok && repo != "" && repo != "operator-framework/operator-sdk" {
101
+ commitSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
102
+ if commitSha == "" {
103
+ commitSha , ok = os .LookupEnv ("TRAVIS_COMMIT" )
104
+ }
105
+ if ok && commitSha != "" {
100
106
gopkg , err := ioutil .ReadFile ("Gopkg.toml" )
101
107
if err != nil {
102
108
t .Fatal (err )
@@ -111,7 +117,7 @@ func TestMemcached(t *testing.T) {
111
117
// correctly.
112
118
gopkgString := string (gopkg )
113
119
gopkgLoc := strings .LastIndex (gopkgString , "\n name = \" github.com/operator-framework/operator-sdk\" \n " )
114
- gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + prSlug + "\" \n revision = \" " + prSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
120
+ gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + repo + "\" \n revision = \" " + commitSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
115
121
err = ioutil .WriteFile ("Gopkg.toml" , []byte (gopkgString ), fileutil .DefaultFileMode )
116
122
if err != nil {
117
123
t .Fatalf ("failed to write updated Gopkg.toml: %v" , err )
@@ -124,7 +130,7 @@ func TestMemcached(t *testing.T) {
124
130
}
125
131
cmdOut , err = exec .Command ("dep" , "ensure" ).CombinedOutput ()
126
132
if err != nil {
127
- t .Fatalf ("error: %v\n Command Output: %s\n " , err , string (cmdOut ))
133
+ t .Fatalf ("error after modifying Gopkg.toml : %v\n Command Output: %s\n " , err , string (cmdOut ))
128
134
}
129
135
130
136
// Set replicas to 2 to test leader election. In production, this should
@@ -217,7 +223,7 @@ func TestMemcached(t *testing.T) {
217
223
t .Fatalf ("dep ensure failed: %v\n Command Output:\n %v" , err , string (cmdOut ))
218
224
}
219
225
// link local sdk to vendor if not in travis
220
- if prSlug == "" {
226
+ if repo == "" {
221
227
os .RemoveAll ("vendor/github.com/operator-framework/operator-sdk/pkg" )
222
228
cmdOut , err = exec .Command ("cp" , "-a" ,
223
229
filepath .Join (gopath , "src/github.com/operator-framework/operator-sdk/pkg" ),
0 commit comments