Skip to content

Commit

Permalink
test(manager-pci-common): add containers test
Browse files Browse the repository at this point in the history
ref: DTCORE-2868
Signed-off-by: Florian Renaut <[email protected]>
  • Loading branch information
frenautvh committed Jan 21, 2025
1 parent 79c07d3 commit 34121a9
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, it, expect, vi } from 'vitest';
import { v6 } from '@ovh-ux/manager-core-api';
import { getServerContainer, TServerContainer } from './container';

describe('getServerContainer', () => {
const mockContainer: TServerContainer = {
createdAt: '2023-01-01T00:00:00Z',
encryption: { sseAlgorithm: 'AES256' },
id: 'containerId',
name: 'containerName',
objects: [],
objectsCount: 0,
objectsSize: 0,
ownerId: 123,
region: 'region',
s3StorageType: 'STANDARD',
storedBytes: 0,
storedObjects: 0,
versioning: { status: 'enabled' },
virtualHost: 'virtualHost',
staticUrl: 'staticUrl',
replication: { rules: [{ status: 'enabled' }] },
};

it('should get server container by id', async () => {
vi.mocked(v6.get).mockResolvedValue({ data: mockContainer });

const result = await getServerContainer(
'projectId',
'region',
'name',
'containerId',
);

expect(v6.get).toHaveBeenCalledWith(
'/cloud/project/projectId/storage/containerId',
);
expect(result).toEqual(mockContainer);
});

it('should get server container by name and region', async () => {
vi.mocked(v6.get).mockResolvedValue({ data: mockContainer });

const result = await getServerContainer(
'projectId',
'region',
'containerName',
'',
);

expect(v6.get).toHaveBeenCalledWith(
'/cloud/project/projectId/region/region/storage/containerName',
);
expect(result).toEqual(mockContainer);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { OdsFile } from '@ovhcloud/ods-components';
import { OdsFileUpload } from '@ovhcloud/ods-components/react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

type FileInputComponentProps = {
Expand Down

0 comments on commit 34121a9

Please sign in to comment.