mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-03 10:52:16 +08:00
* extract resource type * fleet details * new release with fleet * format * type params * format * promote input * format * fleet type * format pls
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import * as manifestStabilityUtils from './manifestStabilityUtils'
|
|
import {Kubectl} from '../types/kubectl'
|
|
import {ResourceTypeFleet, ResourceTypeManagedCluster} from '../actions/deploy'
|
|
import {ExecOutput} from '@actions/exec'
|
|
import {exitCode, stdout} from 'process'
|
|
|
|
describe('manifestStabilityUtils', () => {
|
|
const kc = new Kubectl('')
|
|
const resources = [
|
|
{
|
|
type: 'deployment',
|
|
name: 'test',
|
|
namespace: 'default'
|
|
}
|
|
]
|
|
|
|
it('should return immediately if the resource type is fleet', async () => {
|
|
const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability')
|
|
const checkRolloutStatusSpy = jest.spyOn(kc, 'checkRolloutStatus')
|
|
await manifestStabilityUtils.checkManifestStability(
|
|
kc,
|
|
resources,
|
|
ResourceTypeFleet
|
|
)
|
|
|
|
expect(checkRolloutStatusSpy).not.toHaveBeenCalled()
|
|
expect(spy).toHaveReturned()
|
|
})
|
|
|
|
it('should run fully if the resource type is managedCluster', async () => {
|
|
const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability')
|
|
const checkRolloutStatusSpy = jest
|
|
.spyOn(kc, 'checkRolloutStatus')
|
|
.mockImplementation(() => {
|
|
return new Promise<ExecOutput>((resolve, reject) => {
|
|
resolve({
|
|
exitCode: 0,
|
|
stderr: '',
|
|
stdout: ''
|
|
})
|
|
})
|
|
})
|
|
await manifestStabilityUtils.checkManifestStability(
|
|
kc,
|
|
resources,
|
|
ResourceTypeManagedCluster
|
|
)
|
|
|
|
expect(checkRolloutStatusSpy).toHaveBeenCalled()
|
|
expect(spy).toHaveReturned()
|
|
})
|
|
})
|