-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make data connection bucket field mandatory
- Loading branch information
1 parent
756f19b
commit 3c8adab
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
frontend/src/pages/projects/screens/spawner/__tests__/spawnerUtils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |