@@ -9,17 +9,21 @@ test.beforeEach(() => {
99 mock ( {
1010 '/ws/workflows' : { } ,
1111 '/ws/openfn.yaml' : jsonToYaml ( {
12- name : 'some-project-name' ,
13- workflowRoot : 'workflows' ,
14- formats : {
15- openfn : 'yaml' ,
16- project : 'yaml' ,
17- workflow : 'yaml' ,
12+ project : {
13+ id : 'my-project' ,
14+ } ,
15+ workspace : {
16+ workflowRoot : 'workflows' ,
17+ formats : {
18+ openfn : 'yaml' ,
19+ project : 'yaml' ,
20+ workflow : 'yaml' ,
21+ } ,
1822 } ,
1923 } ) ,
2024 '/ws/.projects/staging@app.openfn.org.yaml' : jsonToYaml ( {
21- id : 'some-id ' ,
22- name : 'some-project-name ' ,
25+ id : '<uuid:staging>> ' ,
26+ name : 'My Staging ' ,
2327 workflows : [
2428 {
2529 name : 'simple-workflow' ,
@@ -80,8 +84,8 @@ test.beforeEach(() => {
8084 ] ,
8185 } ) ,
8286 '/ws/.projects/project@app.openfn.org.yaml' : jsonToYaml ( {
83- id : 'main-id ' ,
84- name : 'main-project-id ' ,
87+ id : '<uuid: main> ' ,
88+ name : 'My Project ' ,
8589 workflows : [
8690 {
8791 name : 'simple-workflow-main' ,
@@ -149,35 +153,33 @@ const logger = createMockLogger('', { level: 'debug' });
149153test . serial ( 'get active project' , ( t ) => {
150154 const workspace = new Workspace ( '/ws' ) ;
151155 t . is ( workspace . valid , true ) ;
152- t . is ( workspace . activeProjectId , 'some -project-name ' ) ;
156+ t . is ( workspace . activeProjectId , 'my -project' ) ;
153157} ) ;
154158
155159test . serial ( 'checkout: invalid project id' , ( t ) => {
156160 checkoutHandler (
157- { command : 'checkout' , projectName : 'not-known' , projectPath : '/ws' } ,
161+ { command : 'checkout' , projectId : 'not-known' , projectPath : '/ws' } ,
158162 logger
159163 ) ;
160164 const { message } = logger . _parse ( logger . _last ) ;
161165 t . is ( message , 'Project with id/name not-known not found in the workspace' ) ;
162166} ) ;
163167
164168test . serial ( 'checkout: to a different valid project' , async ( t ) => {
165- // before checkout. some -project-name is active and expanded
169+ // before checkout. my -project is active and expanded
166170 const bcheckout = new Workspace ( '/ws' ) ;
167- t . is ( bcheckout . projectMeta . name , 'some-project-name' ) ;
168- t . is ( bcheckout . getActiveProject ( ) ?. name , 'some-project-name' ) ;
171+ t . is ( bcheckout . activeProject . id , 'my-project' ) ;
169172
170173 await checkoutHandler (
171- { command : 'checkout' , projectName : 'main -project-id ' , projectPath : '/ws' } ,
174+ { command : 'checkout' , projectId : 'my -project' , projectPath : '/ws' } ,
172175 logger
173176 ) ;
174177 const { message } = logger . _parse ( logger . _last ) ;
175178 t . is ( message , 'Expanded project to /ws' ) ;
176179
177- // after checkout. main -project-id is active and expanded
180+ // after checkout. my -project is active and expanded
178181 const acheckout = new Workspace ( '/ws' ) ;
179- t . is ( acheckout . projectMeta . name , 'main-project-id' ) ;
180- t . is ( acheckout . getActiveProject ( ) ?. name , 'main-project-id' ) ;
182+ t . is ( acheckout . activeProject . id , 'my-project' ) ;
181183
182184 // check if files where well expanded
183185 t . deepEqual (
@@ -187,79 +189,74 @@ test.serial('checkout: to a different valid project', async (t) => {
187189} ) ;
188190
189191test . serial ( 'checkout: same id as active' , async ( t ) => {
190- // before checkout. some -project-name is active and expanded
192+ // before checkout. my -project is active and expanded
191193 const bcheckout = new Workspace ( '/ws' ) ;
192- t . is ( bcheckout . projectMeta . name , 'some-project-name' ) ;
193- t . is ( bcheckout . getActiveProject ( ) ?. name , 'some-project-name' ) ;
194+ t . is ( bcheckout . activeProject . id , 'my-project' ) ;
194195
195196 await checkoutHandler (
196197 {
197198 command : 'checkout' ,
198- projectName : 'some -project-name ' ,
199+ projectId : 'my -project' ,
199200 projectPath : '/ws' ,
200201 } ,
201202 logger
202203 ) ;
203204 const { message } = logger . _parse ( logger . _last ) ;
204205 t . is ( message , 'Expanded project to /ws' ) ;
205206
206- // after checkout. main -project-id is active and expanded
207+ // after checkout. my -project is active and expanded
207208 const acheckout = new Workspace ( '/ws' ) ;
208- t . is ( acheckout . projectMeta . name , 'some-project-name' ) ;
209- t . is ( acheckout . getActiveProject ( ) ?. name , 'some-project-name' ) ;
209+ t . is ( acheckout . activeProject . id , 'my-project' ) ;
210210
211211 // check if files where well expanded
212212 t . deepEqual (
213213 fs . readdirSync ( '/ws/workflows' ) . sort ( ) ,
214- [ 'simple-workflow' , 'another-workflow' ] . sort ( )
214+ [ 'simple-workflow-main ' , 'another-workflow-main ' ] . sort ( )
215215 ) ;
216216} ) ;
217217
218218test . serial ( 'checkout: switching to and back between projects' , async ( t ) => {
219- // before checkout. some -project-name is active and expanded
219+ // before checkout. my -project is active and expanded
220220 const bcheckout = new Workspace ( '/ws' ) ;
221- t . is ( bcheckout . projectMeta . name , 'some-project-name' ) ;
222- t . is ( bcheckout . getActiveProject ( ) ?. name , 'some-project-name' ) ;
221+ t . is ( bcheckout . activeProject . id , 'my-project' ) ;
223222
224- // 1. switch from some -project-name to main-project-id
223+ // 1. switch from my -project to my-staging
225224 await checkoutHandler (
226- { command : 'checkout' , projectName : 'main-project-id ' , projectPath : '/ws' } ,
225+ { command : 'checkout' , projectId : 'my-staging ' , projectPath : '/ws' } ,
227226 logger
228227 ) ;
229228 const { message } = logger . _parse ( logger . _last ) ;
230229 t . is ( message , 'Expanded project to /ws' ) ;
231230
232- // after checkout. main-project-id is active and expanded
231+ // after checkout. my-staging is active and expanded
233232 const acheckout = new Workspace ( '/ws' ) ;
234- t . is ( acheckout . projectMeta . name , 'main-project-id' ) ;
235- t . is ( acheckout . getActiveProject ( ) ?. name , 'main-project-id' ) ;
233+ t . is ( acheckout . activeProject . id , 'my-staging' ) ;
236234
237235 // check if files where well expanded
238236 t . deepEqual (
239237 fs . readdirSync ( '/ws/workflows' ) . sort ( ) ,
240- [ 'simple-workflow-main ' , 'another-workflow-main ' ] . sort ( )
238+ [ 'simple-workflow' , 'another-workflow' ] . sort ( )
241239 ) ;
242240
243- // 2. switch back from main -project-id to some -project-name
241+ // 2. switch back from my -project to my -project
244242 await checkoutHandler (
245243 {
246244 command : 'checkout' ,
247- projectName : 'some -project-name ' ,
245+ projectId : 'my -project' ,
248246 projectPath : '/ws' ,
249247 } ,
250248 logger
251249 ) ;
252250 const { message : lastMsg } = logger . _parse ( logger . _last ) ;
253251 t . is ( lastMsg , 'Expanded project to /ws' ) ;
254252
255- // after checkout. main -project-id is active and expanded
253+ // after checkout. my -project is active and expanded
256254 const fcheckout = new Workspace ( '/ws' ) ;
257- t . is ( fcheckout . projectMeta . name , 'some-project-name' ) ;
258- t . is ( fcheckout . getActiveProject ( ) ?. name , 'some-project-name' ) ;
255+ t . is ( fcheckout . activeProject . id , 'my-project' ) ;
259256
260257 // check if files where well expanded
261258 t . deepEqual (
262259 fs . readdirSync ( '/ws/workflows' ) . sort ( ) ,
263- [ 'simple-workflow' , 'another-workflow' ] . sort ( )
260+ [ 'simple-workflow-main ' , 'another-workflow-main ' ] . sort ( )
264261 ) ;
265262} ) ;
0 commit comments