github.com/unionj-cloud/go-doudou@v1.3.8-0.20221011095552-0088008e5b31/cmd/internal/svc/codegen/k8sdeployment_test.go (about) 1 package codegen 2 3 import ( 4 "fmt" 5 "github.com/unionj-cloud/go-doudou/toolkit/pathutils" 6 "os" 7 "path/filepath" 8 "testing" 9 ) 10 11 func TestModifyVersion(t *testing.T) { 12 type args struct { 13 yfile string 14 } 15 tests := []struct { 16 name string 17 args args 18 }{ 19 { 20 name: "", 21 args: args{ 22 yfile: pathutils.Abs("./testdata/k8s.yaml"), 23 }, 24 }, 25 } 26 for _, tt := range tests { 27 t.Run(tt.name, func(t *testing.T) { 28 result := modifyVersion(tt.args.yfile, "v1.0.0") 29 fmt.Println(string(result)) 30 }) 31 } 32 } 33 34 func TestModifyVersion2(t *testing.T) { 35 type args struct { 36 yfile string 37 } 38 tests := []struct { 39 name string 40 args args 41 }{ 42 { 43 name: "", 44 args: args{ 45 yfile: pathutils.Abs("./testdata/corpus_statefulset.yaml"), 46 }, 47 }, 48 } 49 for _, tt := range tests { 50 t.Run(tt.name, func(t *testing.T) { 51 result := modifyVersion(tt.args.yfile, "v1.0.0") 52 fmt.Println(string(result)) 53 }) 54 } 55 } 56 57 func TestGenK8sDeployment(t *testing.T) { 58 type args struct { 59 dir string 60 svcname string 61 image string 62 } 63 tests := []struct { 64 name string 65 args args 66 }{ 67 { 68 name: "", 69 args: args{ 70 dir: pathutils.Abs("./testdata"), 71 svcname: "corpus", 72 image: "google.com/corpus:v2.0.0", 73 }, 74 }, 75 } 76 for _, tt := range tests { 77 t.Run(tt.name, func(t *testing.T) { 78 GenK8sDeployment(tt.args.dir, tt.args.svcname, tt.args.image) 79 }) 80 } 81 } 82 83 func TestGenK8sDeployment2(t *testing.T) { 84 os.MkdirAll(filepath.Join("testdata", "nodeployment"), os.ModePerm) 85 defer os.RemoveAll(filepath.Join("testdata", "nodeployment")) 86 type args struct { 87 dir string 88 svcname string 89 image string 90 } 91 tests := []struct { 92 name string 93 args args 94 }{ 95 { 96 name: "", 97 args: args{ 98 dir: filepath.Join("testdata", "nodeployment"), 99 svcname: "corpus", 100 image: "google.com/corpus:v2.0.0", 101 }, 102 }, 103 } 104 for _, tt := range tests { 105 t.Run(tt.name, func(t *testing.T) { 106 GenK8sDeployment(tt.args.dir, tt.args.svcname, tt.args.image) 107 }) 108 } 109 }