Skip to content

Commit 03643db

Browse files
committed
fix project tests
1 parent b58eaf4 commit 03643db

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

packages/cli/src/projects/handler.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ const projectsHandler = async (options: ProjectsOptions, logger: Logger) => {
1313

1414
logger.success(`Available openfn projects\n\n${workspace
1515
.list()
16-
.map((p) => describeProject(p, p.name === workspace.activeProjectId))
16+
.map((p) => describeProject(p, p.id === workspace.activeProjectId))
1717
.join('\n\n')}
1818
`);
1919
};
2020

2121
function describeProject(project: Project, active = false) {
2222
// @ts-ignore
23-
const pId = project.openfn?.uuid;
24-
return `${project.name} ${active ? '(active)' : ''}\n ${
25-
pId || '<project-id>'
26-
}\n workflows:\n${project.workflows
27-
.map((w) => ' - ' + w.name)
28-
.join('\n')}`;
23+
const uuid = project.openfn?.uuid;
24+
return `${project.id} ${active ? '(active)' : ''}\n ${
25+
uuid || '<project-id>'
26+
}\n workflows:\n${project.workflows.map((w) => ' - ' + w.id).join('\n')}`;
2927
}
3028

3129
export default projectsHandler;

packages/cli/test/projects/handler.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ import { jsonToYaml } from '@openfn/project';
77
mock({
88
'no-ws/': { 'some.yaml': 'name: smth' },
99
'/ws/openfn.yaml': jsonToYaml({
10-
name: 'some-project-name',
11-
workflowRoot: 'workflows',
12-
formats: {
13-
openfn: 'yaml',
14-
project: 'yaml',
15-
workflow: 'yaml',
10+
project: {
11+
id: 'my-project',
12+
},
13+
workspace: {
14+
workflowRoot: 'workflows',
15+
formats: {
16+
openfn: 'yaml',
17+
project: 'yaml',
18+
workflow: 'yaml',
19+
},
1620
},
1721
}),
1822
'/ws/.projects/staging@app.openfn.org.yaml': jsonToYaml({
19-
id: 'some-id',
20-
name: 'some-project-name',
23+
id: '<uuid:main>',
24+
name: 'my-project',
2125
workflows: [
2226
{
2327
name: 'simple-workflow',
@@ -93,15 +97,15 @@ test('openfn projects: not a workspace', (t) => {
9397
t.is(message, 'Command was run in an invalid openfn workspace');
9498
});
9599

96-
test('openfn projects: valid workspace', (t) => {
100+
test.only('openfn projects: valid workspace', (t) => {
97101
projectsHandler({ command: 'projects', projectPath: '/ws' }, logger);
98102
const { message, level } = logger._parse(logger._last);
99103
t.is('success', level);
100104
t.is(
101105
`Available openfn projects
102106
103-
some-project-name (active)
104-
some-id
107+
my-project (active)
108+
<uuid:main>
105109
workflows:
106110
- simple-workflow
107111
- another-workflow

0 commit comments

Comments
 (0)