sigs.k8s.io/cluster-api-provider-aws@v1.5.5/cmd/clusterawsadm/ami/helper_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package ami 18 19 import ( 20 "testing" 21 22 "github.com/google/go-cmp/cmp" 23 ) 24 25 func TestAllPatchVersions(t *testing.T) { 26 tests := []struct { 27 name string 28 latestVersion string 29 want []string 30 }{ 31 { 32 name: "Should return 3 different patch versions for v1.23.3", 33 latestVersion: "v1.23.3", 34 want: []string{"v1.23.2", "v1.23.1", "v1.23.0"}, 35 }, 36 { 37 name: "Should return empty patch versions for v1.23.0", 38 latestVersion: "v1.23.0", 39 want: []string{}, 40 }, 41 } 42 for _, tt := range tests { 43 t.Run(tt.name, func(t *testing.T) { 44 got, err := allPatchesForVersion(tt.latestVersion) 45 if err != nil { 46 t.Fatalf("error while fetching patch versions %+v", err) 47 } 48 if !cmp.Equal(got, tt.want) { 49 t.Errorf("allPatchesForVersion() got = %v, want %v", got, tt.want) 50 } 51 }) 52 } 53 }