Skip to content

Commit

Permalink
test: Add test for post-start event and commands
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
  • Loading branch information
RomanNikitenko committed Mar 20, 2023
1 parent 619e7e3 commit a27a3b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tools/build/tests/_data/meta/che-theia-meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@ spec:
- name: remote-endpoint
mountPath: /remote-endpoint
ephemeral: true
events:
preStart:
- init-container-command
postStart:
- init-editor-command
commands:
- id: init-container-command
apply:
component: remote-runtime-injector
- id: init-editor-command
exec:
component: editor-runtime-description
commandLine: 'entrypoint-volume.sh'
14 changes: 13 additions & 1 deletion tools/build/tests/devfile/meta-yaml-to-devfile-yaml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,28 @@ describe('Test MetaYamlToDevfileYaml', () => {
expect(remoteEndpointVolumeComponent.volume.ephemeral).toBeTruthy();

expect(devfileYaml.commands).toBeDefined();
expect(devfileYaml.commands?.length).toBe(1);
expect(devfileYaml.commands?.length).toBe(2);

const devfileFirstCommand = devfileYaml.commands[0];
expect(devfileFirstCommand.id).toBe('init-container-command');
expect(devfileFirstCommand.apply).toStrictEqual({ component: 'remote-runtime-injector' });

const devfileSecondCommand = devfileYaml.commands[1];
expect(devfileSecondCommand.id).toBe('init-editor-command');
expect(devfileSecondCommand.exec).toStrictEqual({
component: 'editor-runtime-description',
commandLine: 'entrypoint-volume.sh',
});

expect(devfileYaml.events).toBeDefined();
expect(devfileYaml.events.preStart).toBeDefined();
expect(devfileYaml.events?.preStart?.length).toBe(1);
const preStartFirstEvent = devfileYaml.events.preStart[0];
expect(preStartFirstEvent).toBe('init-container-command');

const postStartEvent = devfileYaml.events.postStart;
expect(postStartEvent).toBeDefined();
expect(postStartEvent[0]).toBe('init-editor-command');
});

test('che-theia with multiple volumes which have identical name', async () => {
Expand Down

0 comments on commit a27a3b4

Please sign in to comment.