@@ -69,30 +69,6 @@ func TestMemcached(t *testing.T) {
69
69
ctx .AddFinalizerFn (func () error { return os .RemoveAll (path .Join (gopath , "/src/github.com/example-inc/memcached-operator" )) })
70
70
71
71
os .Chdir ("memcached-operator" )
72
-
73
- prSlug , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
74
- if ok {
75
- prSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
76
- if ok {
77
- gopkg , err := ioutil .ReadFile ("Gopkg.toml" )
78
- if err != nil {
79
- t .Fatal (err )
80
- }
81
- // TODO: make this match more complete in case we add another repo tracking master
82
- gopkg = bytes .Replace (gopkg , []byte ("branch = \" master\" " ), []byte ("# branch = \" master\" " ), - 1 )
83
- gopkgString := string (gopkg )
84
- gopkgLoc := strings .LastIndex (gopkgString , "\n name = \" github.com/operator-framework/operator-sdk\" \n " )
85
- gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + prSlug + "\" \n revision = \" " + prSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
86
- err = ioutil .WriteFile ("Gopkg.toml" , []byte (gopkgString ), os .FileMode (filemode ))
87
- cmdOut , err = exec .Command ("dep" , "ensure" ).CombinedOutput ()
88
- if err != nil {
89
- t .Fatalf ("dep ensure after gopkg replace failed: %v\n Command Output: %s\n Gopkg Contents: %s" , err , cmdOut , gopkgString )
90
- }
91
- } else {
92
- t .Fatal ("could not find sha of PR" )
93
- }
94
- }
95
-
96
72
handlerFile , err := os .Create ("pkg/stub/handler.go" )
97
73
if err != nil {
98
74
t .Fatal (err )
@@ -145,6 +121,28 @@ func TestMemcached(t *testing.T) {
145
121
t .Fatalf ("could not rename test/e2e/memcached_test.go.tmpl: %v\n Command Output:\n %v" , err , string (cmdOut ))
146
122
}
147
123
t .Log ("Pulling new dependencies with dep ensure" )
124
+ prSlug , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SLUG" )
125
+ if ok && prSlug != "" {
126
+ prSha , ok := os .LookupEnv ("TRAVIS_PULL_REQUEST_SHA" )
127
+ if ok && prSha != "" {
128
+ gopkg , err := ioutil .ReadFile ("Gopkg.toml" )
129
+ if err != nil {
130
+ t .Fatal (err )
131
+ }
132
+ // TODO: make this match more complete in case we add another repo tracking master
133
+ gopkg = bytes .Replace (gopkg , []byte ("branch = \" master\" " ), []byte ("# branch = \" master\" " ), - 1 )
134
+ gopkgString := string (gopkg )
135
+ gopkgLoc := strings .LastIndex (gopkgString , "\n name = \" github.com/operator-framework/operator-sdk\" \n " )
136
+ gopkgString = gopkgString [:gopkgLoc ] + "\n source = \" https://github.com/" + prSlug + "\" \n revision = \" " + prSha + "\" \n " + gopkgString [gopkgLoc + 1 :]
137
+ err = ioutil .WriteFile ("Gopkg.toml" , []byte (gopkgString ), os .FileMode (filemode ))
138
+ if err != nil {
139
+ t .Fatalf ("failed to write updated Gopkg.toml: %v" , err )
140
+ }
141
+ t .Logf ("Gopkg.toml: %v" , gopkgString )
142
+ } else {
143
+ t .Fatal ("could not find sha of PR" )
144
+ }
145
+ }
148
146
cmdOut , err = exec .Command ("dep" , "ensure" ).CombinedOutput ()
149
147
if err != nil {
150
148
t .Fatalf ("dep ensure failed: %v\n Command Output:\n %v" , err , string (cmdOut ))
0 commit comments