@@ -38,7 +38,7 @@ func TestDeployerDeploy(t *testing.T) {
3838 Blueprint : sb.Blueprint {
3939 Project : & sp.Project {
4040 Deployment : & sp.Deployment {
41- Modules : bundle ,
41+ Bundle : bundle ,
4242 },
4343 },
4444 Global : & sg.Global {
@@ -85,51 +85,56 @@ func TestDeployerDeploy(t *testing.T) {
8585 project : newProject (
8686 "project" ,
8787 sp.ModuleBundle {
88- "main" : {
89- Instance : "instance" ,
90- Name : "module" ,
91- Namespace : "default" ,
92- Registry : "registry" ,
93- Type : "kcl" ,
94- Values : map [string ]string {"key" : "value" },
95- Version : "v1.0.0" ,
88+ Env : "test" ,
89+ Modules : map [string ]sp.Module {
90+ "main" : {
91+ Instance : "instance" ,
92+ Name : "module" ,
93+ Namespace : "default" ,
94+ Registry : "registry" ,
95+ Type : "kcl" ,
96+ Values : map [string ]string {"key" : "value" },
97+ Version : "v1.0.0" ,
98+ },
9699 },
97100 },
98101 ),
99102 files : map [string ]string {
100- mkPath ("dev " , "project" , "env.mod.cue" ): `main: values: { key1: "value1" }` ,
103+ mkPath ("test " , "project" , "env.mod.cue" ): `main: values: { key1: "value1" }` ,
101104 },
102105 dryrun : false ,
103106 validate : func (t * testing.T , r testResult ) {
104107 require .NoError (t , r .err )
105108
106- e , err := afero .Exists (r .fs , mkPath ("dev " , "project" , "main.yaml" ))
109+ e , err := afero .Exists (r .fs , mkPath ("test " , "project" , "main.yaml" ))
107110 require .NoError (t , err )
108111 assert .True (t , e )
109112
110- e , err = afero .Exists (r .fs , mkPath ("dev " , "project" , "mod.cue" ))
113+ e , err = afero .Exists (r .fs , mkPath ("test " , "project" , "mod.cue" ))
111114 require .NoError (t , err )
112115 assert .True (t , e )
113116
114- c , err := afero .ReadFile (r .fs , mkPath ("dev " , "project" , "main.yaml" ))
117+ c , err := afero .ReadFile (r .fs , mkPath ("test " , "project" , "main.yaml" ))
115118 require .NoError (t , err )
116119 assert .Equal (t , "manifest" , string (c ))
117120
118121 mod := `{
119- main: {
120- env: ""
121- instance: "instance"
122- name: "module"
123- namespace: "default"
124- registry: "registry"
125- type: "kcl"
126- values: {
127- key: "value"
122+ env: "test"
123+ modules: {
124+ main: {
125+ instance: "instance"
126+ name: "module"
127+ namespace: "default"
128+ registry: "registry"
129+ type: "kcl"
130+ values: {
131+ key: "value"
132+ }
133+ version: "v1.0.0"
128134 }
129- version: "v1.0.0"
130135 }
131136}`
132- c , err = afero .ReadFile (r .fs , mkPath ("dev " , "project" , "mod.cue" ))
137+ c , err = afero .ReadFile (r .fs , mkPath ("test " , "project" , "mod.cue" ))
133138 require .NoError (t , err )
134139 assert .Equal (t , mod , string (c ))
135140
@@ -153,7 +158,8 @@ func TestDeployerDeploy(t *testing.T) {
153158 project : newProject (
154159 "project" ,
155160 sp.ModuleBundle {
156- "main" : {
161+ Env : "test" ,
162+ Modules : map [string ]sp.Module {"main" : {
157163 Instance : "instance" ,
158164 Name : "module" ,
159165 Namespace : "default" ,
@@ -162,38 +168,39 @@ func TestDeployerDeploy(t *testing.T) {
162168 Values : map [string ]string {"key" : "value" },
163169 Version : "v1.0.0" ,
164170 },
171+ },
165172 },
166173 ),
167174 files : map [string ]string {
168- mkPath ("dev " , "project" , "extra.yaml" ): "extra" ,
175+ mkPath ("test " , "project" , "extra.yaml" ): "extra" ,
169176 },
170177 dryrun : true ,
171178 validate : func (t * testing.T , r testResult ) {
172179 require .NoError (t , r .err )
173180
174- e , err := afero .Exists (r .fs , mkPath ("dev " , "project" , "main.yaml" ))
181+ e , err := afero .Exists (r .fs , mkPath ("test " , "project" , "main.yaml" ))
175182 require .NoError (t , err )
176183 assert .True (t , e )
177184
178- e , err = afero .Exists (r .fs , mkPath ("dev " , "project" , "mod.cue" ))
185+ e , err = afero .Exists (r .fs , mkPath ("test " , "project" , "mod.cue" ))
179186 require .NoError (t , err )
180187 assert .True (t , e )
181188
182- e , err = afero .Exists (r .fs , mkPath ("dev " , "project" , "extra.yaml" ))
189+ e , err = afero .Exists (r .fs , mkPath ("test " , "project" , "extra.yaml" ))
183190 require .NoError (t , err )
184191 assert .False (t , e )
185192
186193 wt , err := r .repo .Worktree ()
187194 require .NoError (t , err )
188195 st , err := wt .Status ()
189196 require .NoError (t , err )
190- fst := st .File ("root/dev /project/extra.yaml" )
197+ fst := st .File ("root/test /project/extra.yaml" )
191198 assert .Equal (t , fst .Staging , gg .Deleted )
192199
193- fst = st .File ("root/dev /project/main.yaml" )
200+ fst = st .File ("root/test /project/main.yaml" )
194201 assert .Equal (t , fst .Staging , gg .Added )
195202
196- fst = st .File ("root/dev /project/mod.cue" )
203+ fst = st .File ("root/test /project/mod.cue" )
197204 assert .Equal (t , fst .Staging , gg .Added )
198205
199206 head , err := r .repo .Head ()
@@ -203,6 +210,30 @@ func TestDeployerDeploy(t *testing.T) {
203210 assert .Equal (t , "initial commit" , cm .Message )
204211 },
205212 },
213+ {
214+ name : "deploy to production" ,
215+ project : newProject (
216+ "project" ,
217+ sp.ModuleBundle {
218+ Env : "prod" ,
219+ Modules : map [string ]sp.Module {"main" : {
220+ Instance : "instance" ,
221+ Name : "module" ,
222+ Namespace : "default" ,
223+ Registry : "registry" ,
224+ Type : "kcl" ,
225+ Values : map [string ]string {"key" : "value" },
226+ Version : "v1.0.0" ,
227+ },
228+ },
229+ },
230+ ),
231+ files : map [string ]string {},
232+ dryrun : true ,
233+ validate : func (t * testing.T , r testResult ) {
234+ assert .Error (t , r .err )
235+ },
236+ },
206237 }
207238
208239 for _ , tt := range tests {
@@ -248,7 +279,7 @@ func TestDeployerDeploy(t *testing.T) {
248279 map [deployment.Provider ]func (* slog.Logger ) deployment.ManifestGenerator {
249280 deployment .ProviderKCL : func (logger * slog.Logger ) deployment.ManifestGenerator {
250281 return & dm.ManifestGeneratorMock {
251- GenerateFunc : func (mod sp.Module ) ([]byte , error ) {
282+ GenerateFunc : func (mod sp.Module , env string ) ([]byte , error ) {
252283 return []byte ("manifest" ), nil
253284 },
254285 }
0 commit comments