mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-03-04 00:52:17 +08:00
* case-insensitive resource type * inline error and throw outside switch * consistent input naming * catch failed clustertype parse * protect raw input * naming * format
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import {parseResourceTypeInput} from './inputUtils'
|
|
import {
|
|
ClusterType,
|
|
ResourceTypeFleet,
|
|
ResourceTypeManagedCluster
|
|
} from './actions/deploy'
|
|
|
|
describe('InputUtils', () => {
|
|
describe('parseResourceTypeInput', () => {
|
|
it('should extract fleet exact match resource type', () => {
|
|
expect(
|
|
parseResourceTypeInput('Microsoft.ContainerService/fleets')
|
|
).toEqual(ResourceTypeFleet)
|
|
})
|
|
it('should match fleet case-insensitively', () => {
|
|
expect(
|
|
parseResourceTypeInput('Microsoft.containerservice/fleets')
|
|
).toEqual(ResourceTypeFleet)
|
|
})
|
|
it('should match managed cluster case-insensitively', () => {
|
|
expect(
|
|
parseResourceTypeInput('Microsoft.containerservice/MAnaGedClusterS')
|
|
).toEqual(ResourceTypeManagedCluster)
|
|
})
|
|
it('should error on unexpected values', () => {
|
|
expect(() => {
|
|
parseResourceTypeInput('icrosoft.ContainerService/ManagedCluster')
|
|
}).toThrow()
|
|
expect(() => {
|
|
parseResourceTypeInput('wrong-value')
|
|
}).toThrow()
|
|
})
|
|
})
|
|
})
|