1
1
package operator
2
2
3
3
import (
4
- "encoding/json"
5
4
"fmt"
6
- "io/ioutil"
7
- "os"
8
- "path/filepath"
9
5
"testing"
10
6
"time"
11
7
@@ -127,25 +123,6 @@ func TestOperatorSync_NoOp(t *testing.T) {
127
123
expectedNoop : true ,
128
124
},
129
125
}
130
-
131
- tempDir , err := ioutil .TempDir ("" , "TestOperatorSync" )
132
- if err != nil {
133
- t .Fatalf ("could not create the temp dir: %v" , err )
134
- }
135
- defer os .RemoveAll (tempDir )
136
-
137
- images := Images {
138
- MachineAPIOperator : "test-mao" ,
139
- }
140
- imagesAsJSON , err := json .Marshal (images )
141
- if err != nil {
142
- t .Fatalf ("failed to marshal images: %v" , err )
143
- }
144
- imagesFilePath := filepath .Join (tempDir , "test-images.json" )
145
- if err := ioutil .WriteFile (imagesFilePath , imagesAsJSON , 0666 ); err != nil {
146
- t .Fatalf ("could not write the images file: %v" , err )
147
- }
148
-
149
126
for _ , tc := range cases {
150
127
t .Run (string (tc .platform ), func (t * testing.T ) {
151
128
infra := & v1.Infrastructure {
@@ -158,15 +135,10 @@ func TestOperatorSync_NoOp(t *testing.T) {
158
135
}
159
136
160
137
stopCh := make (<- chan struct {})
161
- optr := newFakeOperator (nil , []runtime.Object {infra }, stopCh )
162
- optr .imagesFile = imagesFilePath
163
-
164
- err = optr .sync ("test-key" )
165
- if ! assert .NoError (t , err , "unexpected sync failure" ) {
166
- t .Fatal ()
167
- }
138
+ optr := newFakeOperator (nil , []runtime.Object {newFeatureGate (v1 .TechPreviewNoUpgrade ), infra }, stopCh )
139
+ go optr .Run (2 , stopCh )
168
140
169
- err = wait .PollImmediate (1 * time .Second , 5 * time .Second , func () (bool , error ) {
141
+ err : = wait .PollImmediate (1 * time .Second , 5 * time .Second , func () (bool , error ) {
170
142
_ , err := optr .deployLister .Deployments (targetNamespace ).Get (deploymentName )
171
143
if err != nil {
172
144
t .Logf ("Failed to get %q deployment: %v" , deploymentName , err )
0 commit comments