istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/echo/cmd/echogen/echogen_test.go (about) 1 // Copyright Istio 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 main 16 17 import ( 18 "bytes" 19 "flag" 20 "testing" 21 22 "istio.io/istio/pilot/test/util" 23 "istio.io/istio/pkg/test/framework/config" 24 ) 25 26 const ( 27 testCfg = "testdata/config.yaml" 28 goldenFile = "testdata/golden.yaml" 29 ) 30 31 func TestGenerate(t *testing.T) { 32 if !config.Parsed() { 33 config.Parse() 34 } 35 flag.VisitAll(func(f *flag.Flag) { 36 // these change often, don't want to regen golden 37 switch f.Name { 38 case "istio.test.tag": 39 _ = f.Value.Set("testtag") 40 case "istio.test.variant": 41 _ = f.Value.Set("testvariant") 42 case "istio.test.hub": 43 _ = f.Value.Set("testhub") 44 case "istio.test.pullpolicy": 45 _ = f.Value.Set("IfNotPresent") 46 } 47 }) 48 out := bytes.NewBuffer([]byte{}) 49 generate(testCfg, "", false, out) 50 util.CompareContent(t, out.Bytes(), goldenFile) 51 }