github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/build/layerutils/charts/helm_test.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package charts 16 17 import ( 18 "reflect" 19 "sort" 20 "testing" 21 ) 22 23 func TestGetImageList(t *testing.T) { 24 type args struct { 25 chartPath string 26 } 27 tests := []struct { 28 name string 29 args args 30 want []string 31 wantErr bool 32 }{ 33 { 34 "test get image list in chart", 35 args{"./testcharts/apps"}, 36 []string{"nginx:apps_release", "nginx:app1_release", "nginx:app2_test"}, 37 false, 38 }, 39 } 40 for _, tt := range tests { 41 t.Run(tt.name, func(t *testing.T) { 42 images, err := GetImageList(tt.args.chartPath) 43 if (err != nil) != tt.wantErr { 44 t.Errorf("GetImageList() error = %v, wantErr %v", err, tt.wantErr) 45 return 46 } 47 sort.Strings(images) 48 sort.Strings(tt.want) 49 if !reflect.DeepEqual(images, tt.want) { 50 t.Errorf("GetImageList() error get %v, want %v", images, tt.want) 51 return 52 } 53 }) 54 } 55 }