@@ -82,10 +82,16 @@ func TestMemcached(t *testing.T) {
82
82
ctx .AddFinalizerFn (func () error { return os .RemoveAll (absProjectPath ) })
83
83
84
84
os .Chdir ("memcached-operator" )
85
- prSlug , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
86
- if ok && prSlug != "" {
87
- prSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
88
- if ok && prSha != "" {
85
+ repo , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
86
+ if repo == "" {
87
+ repo , ok = os .LookupEnv ("TRAVIS_REPO_SLUG" )
88
+ }
89
+ if ok && repo != "" {
90
+ commitSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
91
+ if commitSha == "" {
92
+ commitSha , ok = os .LookupEnv ("TRAVIS_COMMIT" )
93
+ }
94
+ if ok && commitSha != "" {
89
95
gopkg , err := ioutil .ReadFile ("Gopkg.toml" )
90
96
if err != nil {
91
97
t .Fatal (err )
@@ -98,7 +104,7 @@ func TestMemcached(t *testing.T) {
98
104
// correctly.
99
105
gopkgString := string (gopkg )
100
106
gopkgLoc := strings .LastIndex (gopkgString , "\n name = \" github.com/operator-framework/operator-sdk\" \n " )
101
- gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + prSlug + "\" \n revision = \" " + prSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
107
+ gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + repo + "\" \n revision = \" " + commitSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
102
108
err = ioutil .WriteFile ("Gopkg.toml" , []byte (gopkgString ), filemode )
103
109
if err != nil {
104
110
t .Fatalf ("failed to write updated Gopkg.toml: %v" , err )
@@ -111,7 +117,7 @@ func TestMemcached(t *testing.T) {
111
117
}
112
118
cmdOut , err = exec .Command ("dep" , "ensure" ).CombinedOutput ()
113
119
if err != nil {
114
- t .Fatalf ("error: %v\n Command Output: %s\n " , err , string (cmdOut ))
120
+ t .Fatalf ("error after modifying Gopkg.toml : %v\n Command Output: %s\n " , err , string (cmdOut ))
115
121
}
116
122
117
123
cmdOut , err = exec .Command ("operator-sdk" ,
@@ -191,7 +197,7 @@ func TestMemcached(t *testing.T) {
191
197
t .Fatalf ("dep ensure failed: %v\n Command Output:\n %v" , err , string (cmdOut ))
192
198
}
193
199
// link local sdk to vendor if not in travis
194
- if prSlug == "" {
200
+ if repo == "" {
195
201
os .RemoveAll ("vendor/github.com/operator-framework/operator-sdk/pkg" )
196
202
os .Symlink (filepath .Join (gopath , "src/github.com/operator-framework/operator-sdk/pkg" ),
197
203
"vendor/github.com/operator-framework/operator-sdk/pkg" )
0 commit comments