Skip to content

Commit

Permalink
fixed workbench image number dep
Browse files Browse the repository at this point in the history
  • Loading branch information
rsun19 committed Jul 10, 2024
1 parent 3e07400 commit 3a94f02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { AwsKeys } from '~/pages/projects/dataConnections/const';
import {
getExistingVersionsForImageStream,
isAWSValid,
checkVersionRecommended, // Added import for the new function
checkVersionRecommended,
getVersion,
} from '~/pages/projects/screens/spawner/spawnerUtils';
import { EnvVariableDataEntry } from '~/pages/projects/types';
import { mockImageStreamK8sResource } from '~/__mocks__/mockImageStreamK8sResource';
Expand Down Expand Up @@ -174,4 +175,17 @@ describe('checkVersionRecommended', () => {
};
expect(checkVersionRecommended(imageVersion)).toBe(false);
});

it('should get version with a prefix and string parameter', () => {
expect(getVersion('v3.9', 'v')).toEqual('v3.9');
expect(getVersion('4.9', 'V')).toEqual('V4.9');
expect(getVersion('3.1', 'Randomprefix')).toEqual('Randomprefix3.1');
expect(getVersion('0.1')).toEqual('0.1');
});

it('should get version with a number as the parameter', () => {
expect(getVersion(0.1)).toEqual('0.1');
expect(getVersion(3.1, 'v')).toEqual('v3.1');
expect(getVersion(1000.5, 'V')).toEqual('V1000.5');
});
});
5 changes: 4 additions & 1 deletion frontend/src/pages/projects/screens/spawner/spawnerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ export const useMergeDefaultPVCName = (
};
};

export const getVersion = (version?: string, prefix?: string): string => {
export const getVersion = (version?: string | number, prefix?: string): string => {
if (!version) {
return '';
}
if (typeof version === 'number') {
return `${prefix || ''}${version}`;
}
const versionString =
version.startsWith('v') || version.startsWith('V') ? version.slice(1) : version;

Expand Down

0 comments on commit 3a94f02

Please sign in to comment.