-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Construct LogEvent filter from params. Validate buildStartLiveTailCom…
…mand in unit tests
- Loading branch information
Keegan Irby
committed
Nov 13, 2024
1 parent
30d9217
commit 4d3b7f6
Showing
2 changed files
with
99 additions
and
1 deletion.
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
97 changes: 97 additions & 0 deletions
97
packages/core/src/test/awsService/cloudWatchLogs/registry/liveTailSession.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,97 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import assert from 'assert' | ||
import { LiveTailSession } from '../../../../awsService/cloudWatchLogs/registry/liveTailSession' | ||
import { StartLiveTailCommand } from '@aws-sdk/client-cloudwatch-logs' | ||
describe('LiveTailSession', async function () { | ||
const testLogGroupArn = 'arn:aws:test-log-group' | ||
const testRegion = 'test-region' | ||
const testFilter = 'test-filter' | ||
const testAwsCredentials = {} as any as AWS.Credentials | ||
it('correctly builds StartLiveTailCommand: no stream Filter, no event filter.', function () { | ||
const session = new LiveTailSession({ | ||
logGroupArn: testLogGroupArn, | ||
region: testRegion, | ||
awsCredentials: testAwsCredentials, | ||
}) | ||
assert.strictEqual( | ||
JSON.stringify(session.buildStartLiveTailCommand()), | ||
JSON.stringify( | ||
new StartLiveTailCommand({ | ||
logGroupIdentifiers: [testLogGroupArn], | ||
logEventFilterPattern: undefined, | ||
logStreamNamePrefixes: undefined, | ||
logStreamNames: undefined, | ||
}) | ||
) | ||
) | ||
}) | ||
it('correctly builds StartLiveTailCommand: with prefix stream Filter', function () { | ||
const session = new LiveTailSession({ | ||
logGroupArn: testLogGroupArn, | ||
logStreamFilter: { | ||
type: 'prefix', | ||
filter: 'test-filter', | ||
}, | ||
region: testRegion, | ||
awsCredentials: testAwsCredentials, | ||
}) | ||
assert.strictEqual( | ||
JSON.stringify(session.buildStartLiveTailCommand()), | ||
JSON.stringify( | ||
new StartLiveTailCommand({ | ||
logGroupIdentifiers: [testLogGroupArn], | ||
logEventFilterPattern: undefined, | ||
logStreamNamePrefixes: [testFilter], | ||
logStreamNames: undefined, | ||
}) | ||
) | ||
) | ||
}) | ||
it('correctly builds StartLiveTailCommand: with specific stream Filter', function () { | ||
const session = new LiveTailSession({ | ||
logGroupArn: testLogGroupArn, | ||
logStreamFilter: { | ||
type: 'specific', | ||
filter: 'test-filter', | ||
}, | ||
region: testRegion, | ||
awsCredentials: testAwsCredentials, | ||
}) | ||
assert.strictEqual( | ||
JSON.stringify(session.buildStartLiveTailCommand()), | ||
JSON.stringify( | ||
new StartLiveTailCommand({ | ||
logGroupIdentifiers: [testLogGroupArn], | ||
logEventFilterPattern: undefined, | ||
logStreamNamePrefixes: undefined, | ||
logStreamNames: [testFilter], | ||
}) | ||
) | ||
) | ||
}) | ||
it('correctly builds StartLiveTailCommand: with log event Filter', function () { | ||
const session = new LiveTailSession({ | ||
logGroupArn: testLogGroupArn, | ||
logStreamFilter: { | ||
type: 'all', | ||
}, | ||
logEventFilterPattern: 'test-filter', | ||
region: testRegion, | ||
awsCredentials: testAwsCredentials, | ||
}) | ||
assert.strictEqual( | ||
JSON.stringify(session.buildStartLiveTailCommand()), | ||
JSON.stringify( | ||
new StartLiveTailCommand({ | ||
logGroupIdentifiers: [testLogGroupArn], | ||
logEventFilterPattern: testFilter, | ||
logStreamNamePrefixes: undefined, | ||
logStreamNames: undefined, | ||
}) | ||
) | ||
) | ||
}) | ||
}) |