Skip to content

Commit 1235fb6

Browse files
committed
fixup! fix: adding starterProjects attributes
Signed-off-by: Oleksii Orel <oorel@redhat.com>
1 parent 04187ca commit 1235fb6

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

tests/generate.spec.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,77 @@ metadata:
9292
test('basics', async () => {
9393
const devfileContent = `
9494
schemaVersion: 2.2.0
95+
metadata:
96+
name: starter-project
97+
starterProjects:
98+
- name: go-starter
99+
description: A Go project
100+
git:
101+
checkoutFrom:
102+
revision: main
103+
remotes:
104+
origin: https://github.com/devfile-samples/devfile-stack-go.git
105+
- name: vertx-http-example
106+
git:
107+
remotes:
108+
origin: https://github.com
109+
`;
110+
const editorContent = `
111+
schemaVersion: 2.2.0
112+
metadata:
113+
name: che-code
114+
`;
115+
116+
const fsWriteFileSpy = jest.spyOn(fs, 'writeFile');
117+
fsWriteFileSpy.mockReturnValue({});
118+
119+
let context = await generate.generate(devfileContent, editorContent);
120+
// expect not to write the file
121+
expect(fsWriteFileSpy).not.toBeCalled();
122+
const expectedDevWorkspace = {
123+
apiVersion: 'workspace.devfile.io/v1alpha2',
124+
kind: 'DevWorkspace',
125+
metadata: {
126+
name: 'starter-project',
127+
},
128+
spec: {
129+
started: true,
130+
routingClass: 'che',
131+
template: {
132+
attributes: {
133+
'controller.devfile.io/use-starter-project': 'go-starter',
134+
},
135+
starterProjects: [
136+
{
137+
name: 'go-starter',
138+
description: 'A Go project',
139+
git: {
140+
checkoutFrom: {
141+
revision: 'main',
142+
},
143+
remotes: {
144+
origin: 'https://github.com/devfile-samples/devfile-stack-go.git',
145+
},
146+
},
147+
},
148+
{
149+
name: 'vertx-http-example',
150+
git: {
151+
remotes: {
152+
origin: 'https://github.com',
153+
},
154+
},
155+
},
156+
],
157+
},
158+
contributions: [{ name: 'editor', kubernetes: { name: 'che-code-starter-project' } }],
159+
},
160+
};
161+
expect(context.devWorkspace).toStrictEqual(expectedDevWorkspace);
162+
});
163+
test('with storage-type attribute', async () => {
164+
const devfileContent = `
165+
schemaVersion: 2.2.0
95166
metadata:
96167
name: starter-project
97168
attributes:

0 commit comments

Comments
 (0)