Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import * as vscode from 'vscode'
import { CLOUDWATCH_LOGS_LIVETAIL_SCHEME } from '../../../shared/constants'
import { LiveTailSession, LiveTailSessionConfiguration } from './liveTailSession'
import { ToolkitError } from '../../../shared'
import { NestedMap } from '../../../shared/utilities/map'

export class LiveTailSessionRegistry extends NestedMap<vscode.Uri, LiveTailSession> {
export class LiveTailSessionRegistry extends Map<vscode.Uri, LiveTailSession> {
static #instance: LiveTailSessionRegistry

public static get instance() {
Expand All @@ -18,18 +16,6 @@ export class LiveTailSessionRegistry extends NestedMap<vscode.Uri, LiveTailSessi
public constructor() {
super()
}

protected override hash(uri: vscode.Uri): string {
return uri.toString()
}

protected override get name(): string {
return LiveTailSessionRegistry.name
}

protected override get default(): LiveTailSession {
throw new ToolkitError('No LiveTailSession found for provided uri.')
}
}

export function createLiveTailURIFromArgs(sessionData: LiveTailSessionConfiguration): vscode.Uri {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,10 @@
*/
import * as vscode from 'vscode'
import assert from 'assert'
import {
LiveTailSession,
LiveTailSessionConfiguration,
} from '../../../../awsService/cloudWatchLogs/registry/liveTailSession'
import {
createLiveTailURIFromArgs,
LiveTailSessionRegistry,
} from '../../../../awsService/cloudWatchLogs/registry/liveTailSessionRegistry'
import { LiveTailSessionConfiguration } from '../../../../awsService/cloudWatchLogs/registry/liveTailSession'
import { createLiveTailURIFromArgs } from '../../../../awsService/cloudWatchLogs/registry/liveTailSessionRegistry'
import { CLOUDWATCH_LOGS_LIVETAIL_SCHEME } from '../../../../shared/constants'

/**
* Exposes protected methods so we can test them
*/
class TestLiveTailSessionRegistry extends LiveTailSessionRegistry {
constructor() {
super()
}

override hash(uri: vscode.Uri): string {
return super.hash(uri)
}

override get default(): LiveTailSession {
return super.default
}
}

describe('LiveTailRegistry', async function () {
const session = new LiveTailSession({
logGroupName: 'test-log-group',
region: 'test-region',
})

let liveTailSessionRegistry: TestLiveTailSessionRegistry

beforeEach(function () {
liveTailSessionRegistry = new TestLiveTailSessionRegistry()
})

it('hash()', function () {
assert.deepStrictEqual(liveTailSessionRegistry.hash(session.uri), session.uri.toString())
})

it('default()', function () {
assert.throws(() => liveTailSessionRegistry.default)
})
})

describe('LiveTailSession URI', async function () {
const testLogGroupName = 'test-log-group'
const testRegion = 'test-region'
Expand Down
Loading