15
15
package release
16
16
17
17
import (
18
- "bytes"
19
- "encoding/json"
20
18
"testing"
21
19
22
20
"github.com/stretchr/testify/assert"
@@ -249,20 +247,11 @@ func TestManagerisUpgrade(t *testing.T) {
249
247
name : "different values" ,
250
248
releaseName : "deployed" ,
251
249
releaseNs : "deployed-ns" ,
252
- values : map [string ]interface {}{"key" : "1" , "int" : int32 ( 1 ) },
250
+ values : map [string ]interface {}{"key" : "1" },
253
251
chart : newTestChart (t , "./testdata/simple" ),
254
- deployedRelease : newTestRelease (newTestChart (t , "./testdata/simple" ), map [string ]interface {}{"key" : "" , "int" : int64 ( 1 ) }, "deployed" , "deployed-ns" ),
252
+ deployedRelease : newTestRelease (newTestChart (t , "./testdata/simple" ), map [string ]interface {}{"key" : "" }, "deployed" , "deployed-ns" ),
255
253
want : true ,
256
254
},
257
- {
258
- name : "nil values" ,
259
- releaseName : "deployed" ,
260
- releaseNs : "deployed-ns" ,
261
- values : nil ,
262
- chart : newTestChart (t , "./testdata/simple" ),
263
- deployedRelease : newTestRelease (newTestChart (t , "./testdata/simple" ), map [string ]interface {}{}, "deployed" , "deployed-ns" ),
264
- want : false ,
265
- },
266
255
}
267
256
for _ , test := range tests {
268
257
t .Run (test .name , func (t * testing.T ) {
@@ -272,9 +261,8 @@ func TestManagerisUpgrade(t *testing.T) {
272
261
values : test .values ,
273
262
chart : test .chart ,
274
263
}
275
- isUpgrade , err := m .isUpgrade (test .deployedRelease )
264
+ isUpgrade := m .isUpgrade (test .deployedRelease )
276
265
assert .Equal (t , test .want , isUpgrade )
277
- assert .Equal (t , nil , err )
278
266
})
279
267
}
280
268
}
@@ -285,16 +273,13 @@ func newTestChart(t *testing.T, path string) *cpb.Chart {
285
273
return chart
286
274
}
287
275
288
- func newTestRelease (chart * cpb.Chart , values map [string ]interface {}, name , namespace string ) * rpb.Release { // nolint: unparam
276
+ func newTestRelease (chart * cpb.Chart , values map [string ]interface {}, name , namespace string ) * rpb.Release {
289
277
release := rpb .Mock (& rpb.MockReleaseOptions {
290
278
Name : name ,
291
279
Namespace : namespace ,
280
+ Chart : chart ,
292
281
Version : 1 ,
293
282
})
294
-
295
- buffer := & bytes.Buffer {}
296
- _ = json .NewEncoder (buffer ).Encode (chart )
297
- _ = json .NewDecoder (buffer ).Decode (release .Chart )
298
283
release .Config = values
299
284
return release
300
285
}
0 commit comments