Skip to content

Commit

Permalink
Make data connection bucket field mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Oct 10, 2023
1 parent 756f19b commit 3c8adab
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/pages/projects/dataConnections/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const AWS_FIELDS: FieldOptions[] = [
{
key: AWS_KEYS.AWS_S3_BUCKET,
label: 'Bucket',
isRequired: true,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { AWS_KEYS } from '~/pages/projects/dataConnections/const';
import { isAWSValid } from '~/pages/projects/screens/spawner/spawnerUtils';
import { EnvVariableDataEntry } from '~/pages/projects/types';

describe('isAWSValid', () => {
const getMockAWSData = ({
name = 'test-name',
accessKey = 'test-access-key',
accessSecret = 'test-access-secret',
bucket = 'test-bucket',
endpoint = 'test-endpoint',
region = '',
}): EnvVariableDataEntry[] => [
{
key: AWS_KEYS.NAME,
value: name,
},
{
key: AWS_KEYS.ACCESS_KEY_ID,
value: accessKey,
},
{
key: AWS_KEYS.SECRET_ACCESS_KEY,
value: accessSecret,
},
{
key: AWS_KEYS.S3_ENDPOINT,
value: endpoint,
},
{
key: AWS_KEYS.DEFAULT_REGION,
value: region,
},
{
key: AWS_KEYS.AWS_S3_BUCKET,
value: bucket,
},
];

it('should be valid when all the required fields are met', () => {
expect(isAWSValid(getMockAWSData({}))).toBe(true);
});

it('should be invalid when the name field is missing', () => {
expect(isAWSValid(getMockAWSData({ name: '' }))).toBe(false);
});

it('should be invalid when the access key field is missing', () => {
expect(isAWSValid(getMockAWSData({ accessKey: '' }))).toBe(false);
});

it('should be invalid when the secret key field is missing', () => {
expect(isAWSValid(getMockAWSData({ accessSecret: '' }))).toBe(false);
});

it('should be invalid when the endpoint field is missing', () => {
expect(isAWSValid(getMockAWSData({ endpoint: '' }))).toBe(false);
});

it('should be invalid when the bucket field is missing', () => {
expect(isAWSValid(getMockAWSData({ bucket: '' }))).toBe(false);
});
});

0 comments on commit 3c8adab

Please sign in to comment.