-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle rejected logs, new unit tests
- Loading branch information
1 parent
61622ba
commit fee80f1
Showing
6 changed files
with
158 additions
and
50 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
34 changes: 34 additions & 0 deletions
34
packages/logging/__tests__/providers/cloudwatch/utils/utils.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,34 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { getDefaultStreamName } from '../../../../src/providers/cloudwatch/utils'; | ||
import { fetchAuthSession } from '@aws-amplify/core'; | ||
|
||
const mockFetchAuthSession = fetchAuthSession as jest.Mock; | ||
const testDeviceId = 'test-device-id-1'; | ||
|
||
jest.mock('@aws-amplify/core'); | ||
jest.mock('@aws-amplify/core/internals/utils', () => ({ | ||
...jest.requireActual('@aws-amplify/core/internals/utils'), | ||
getDeviceId: jest.fn(() => testDeviceId), | ||
})); | ||
|
||
describe('CloudWatch Utils: ', () => { | ||
describe('getDefaultStreamName', () => { | ||
it('should return a log stream name for a guest', async () => { | ||
mockFetchAuthSession.mockImplementationOnce(() => { | ||
return { userSub: undefined }; | ||
}); | ||
expect(await getDefaultStreamName()).toContain(`${testDeviceId}.guest`); | ||
}); | ||
it('should return a log stream name for a logged in user', async () => { | ||
const loggedInUserSub = 'test-logged-in-user-sub'; | ||
mockFetchAuthSession.mockImplementationOnce(() => { | ||
return { userSub: loggedInUserSub }; | ||
}); | ||
expect(await getDefaultStreamName()).toContain( | ||
`${testDeviceId}.${loggedInUserSub}` | ||
); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export { getDefaultStreamName } from './utils'; | ||
export { getDefaultStreamName, parseRejectedLogEvents } from './utils'; |
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