forked from aws-amplify/amplify-category-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aws-amplify#1698 from sundersc/rds-merge-to-main
- Loading branch information
Showing
92 changed files
with
2,800 additions
and
1,212 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
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
71 changes: 71 additions & 0 deletions
71
...fy-category-api/src/__tests__/provider-utils/awscloudformation/utils/database-url.test.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,71 @@ | ||
import { parseDatabaseUrl } from '../../../../provider-utils/awscloudformation/utils/database-url'; | ||
|
||
describe('parseDatabaseUrl', () => { | ||
it('should parse a valid database url', () => { | ||
const databaseUrl = 'mysql://username:password@localhost:3306/database'; | ||
const expected = { | ||
engine: 'mysql', | ||
username: 'username', | ||
password: 'password', | ||
database: 'database', | ||
host: 'localhost', | ||
port: 3306, | ||
}; | ||
const actual = parseDatabaseUrl(databaseUrl); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('should parse a valid database url without port', () => { | ||
const databaseUrl = 'mysql://username:password@localhost/database'; | ||
const expected = { | ||
engine: 'mysql', | ||
username: 'username', | ||
password: 'password', | ||
database: 'database', | ||
host: 'localhost', | ||
port: NaN, | ||
}; | ||
const actual = parseDatabaseUrl(databaseUrl); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('should parse a valid database url without username and password', () => { | ||
const databaseUrl = 'mysql://localhost:3306/database'; | ||
const expected = { | ||
engine: 'mysql', | ||
username: '', | ||
password: '', | ||
database: 'database', | ||
host: 'localhost', | ||
port: 3306, | ||
}; | ||
const actual = parseDatabaseUrl(databaseUrl); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('should throw an error for an invalid database url', () => { | ||
const databaseUrl = 'http://username:password@localhost:3306/database'; | ||
expect(() => parseDatabaseUrl(databaseUrl)).toThrow('Invalid engine http.'); | ||
}); | ||
|
||
it('should accept uppercase engine name', () => { | ||
const databaseUrl = 'MySQL://username:password@localhost:3306/database'; | ||
const expected = { | ||
engine: 'mysql', | ||
username: 'username', | ||
password: 'password', | ||
database: 'database', | ||
host: 'localhost', | ||
port: 3306, | ||
}; | ||
const actual = parseDatabaseUrl(databaseUrl); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('should return empty object for an invalid database url', () => { | ||
const databaseUrl = '1234567890'; | ||
const expected = {}; | ||
const actual = parseDatabaseUrl(databaseUrl); | ||
expect(actual).toEqual(expected); | ||
}); | ||
}); |
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
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
4 changes: 2 additions & 2 deletions
4
...tils/rds-secrets/database-secrets.test.ts → ...ls/rds-secrets/database-resources.test.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
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
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
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
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
Oops, something went wrong.