github.com/SamarSidharth/kpt@v0.0.0-20231122062228-c7d747ae3ace/internal/testutil/pkgbuilder/builder_test.go (about) 1 // Copyright 2023 The kpt Authors 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 pkgbuilder 16 17 import ( 18 "testing" 19 20 "github.com/google/go-cmp/cmp" 21 ) 22 23 func TestBuildKptfile(t *testing.T) { 24 var repos ReposInfo 25 pkg := &pkg{} 26 pkg.Kptfile = &Kptfile{ 27 Pipeline: &Pipeline{ 28 Functions: []Function{ 29 {Image: "example.com/fn1"}, 30 {ConfigPath: "config1"}, 31 {Image: "example.com/fn2"}, 32 }, 33 }, 34 } 35 36 got := buildKptfile(pkg, "test1", repos) 37 want := `apiVersion: kpt.dev/v1 38 kind: Kptfile 39 metadata: 40 name: test1 41 pipeline: 42 mutators: 43 - image: example.com/fn1 44 - configPath: config1 45 - image: example.com/fn2 46 ` 47 48 if diff := cmp.Diff(want, got); diff != "" { 49 t.Errorf("buildKptfile returned unexpected diff (-want +got):\n%s", diff) 50 } 51 }