Skip to content

Commit

Permalink
move test branch to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 committed Nov 5, 2024
1 parent 2f36522 commit b379009
Showing 1 changed file with 176 additions and 0 deletions.
176 changes: 176 additions & 0 deletions react/src/helper/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
addNumberWithUnits,
compareNumberWithUnits,
filterEmptyItem,
getImageFullName,
iSizeToSize,
isOutsideRange,
isOutsideRangeWithUnits,
Expand Down Expand Up @@ -351,3 +352,178 @@ describe('toFixedFloorWithoutTrailingZeros', () => {
expect(toFixedFloorWithoutTrailingZeros('1.097', 2)).toEqual('1.1');
});
});

describe('getImageFullName', () => {
it('should return the full image name using only the namespace if there is a namespace but no name.', () => {
const result =
getImageFullName({
namespace: 'abc/def/training',
name: undefined,
humanized_name: 'abc/def/training',
tag: '01-py3-abc-v1-def',
registry: '192.168.0.1:7080',
architecture: 'x86_64',
digest: 'sha256:123456',
id: 'sample id',
installed: true,
resource_limits: [
{
key: 'cpu',
min: '1',
max: null,
},
{
key: 'mem',
min: '1g',
max: null,
},
{
key: 'cuda.device',
min: '0',
max: null,
},
{
key: 'cuda.shares',
min: '0',
max: null,
},
],
labels: [
{
key: 'maintainer',
value: 'NVIDIA CORPORATION <[email protected]>',
},
],
base_image_name: 'def/training',
tags: [
{
key: 'py3',
value: 'abc',
},
{
key: 'v1',
value: 'def',
},
],
version: '01',
}) || '';
expect(result).toBe(
'192.168.0.1:7080/abc/def/training:01-py3-abc-v1-def@x86_64',
);
});
it('should return the full image name using only the name if there is a name but no namespace.', () => {
const result =
getImageFullName({
namespace: undefined,
name: 'abc/def/training',
humanized_name: 'abc/def/training',
tag: '01-py3-abc-v1-def',
registry: '192.168.0.1:7080',
architecture: 'x86_64',
digest: 'sha256:123456',
id: 'sample id',
installed: true,
resource_limits: [
{
key: 'cpu',
min: '1',
max: null,
},
{
key: 'mem',
min: '1g',
max: null,
},
{
key: 'cuda.device',
min: '0',
max: null,
},
{
key: 'cuda.shares',
min: '0',
max: null,
},
],
labels: [
{
key: 'maintainer',
value: 'NVIDIA CORPORATION <[email protected]>',
},
],
base_image_name: 'def/training',
tags: [
{
key: 'py3',
value: 'abc',
},
{
key: 'v1',
value: 'def',
},
],
version: '01',
}) || '';
expect(result).toBe(
'192.168.0.1:7080/abc/def/training:01-py3-abc-v1-def@x86_64',
);
});

it('should return the full image name using namespace if there are both name and namespace.', () => {
const result =
getImageFullName({
namespace: 'abc/def/training',
name: 'ghi/jkl/training',
humanized_name: 'abc/def/training',
tag: '01-py3-abc-v1-def',
registry: '192.168.0.1:7080',
architecture: 'x86_64',
digest: 'sha256:123456',
id: 'sample id',
installed: true,
resource_limits: [
{
key: 'cpu',
min: '1',
max: null,
},
{
key: 'mem',
min: '1g',
max: null,
},
{
key: 'cuda.device',
min: '0',
max: null,
},
{
key: 'cuda.shares',
min: '0',
max: null,
},
],
labels: [
{
key: 'maintainer',
value: 'NVIDIA CORPORATION <[email protected]>',
},
],
base_image_name: 'def/training',
tags: [
{
key: 'py3',
value: 'abc',
},
{
key: 'v1',
value: 'def',
},
],
version: '01',
}) || '';
expect(result).toBe(
'192.168.0.1:7080/abc/def/training:01-py3-abc-v1-def@x86_64',
);
});
});

0 comments on commit b379009

Please sign in to comment.