1
1
import * as manifestStabilityUtils from './manifestStabilityUtils'
2
2
import { Kubectl } from '../types/kubectl'
3
+ import { ResourceTypeFleet , ResourceTypeManagedCluster } from '../actions/deploy'
4
+ import { ExecOutput } from '@actions/exec'
5
+ import { exitCode , stdout } from 'process'
3
6
4
7
describe ( 'manifestStabilityUtils' , ( ) => {
5
8
const kc = new Kubectl ( '' )
@@ -10,18 +13,40 @@ describe('manifestStabilityUtils', () => {
10
13
namespace : 'default'
11
14
}
12
15
]
13
- const resourceType = 'microsoft.containerservice/fleets'
14
16
15
- it ( 'should return immediately if the resource type is microsoft.containerservice/fleets ' , async ( ) => {
17
+ it ( 'should return immediately if the resource type is fleet ' , async ( ) => {
16
18
const spy = jest . spyOn ( manifestStabilityUtils , 'checkManifestStability' )
17
19
const checkRolloutStatusSpy = jest . spyOn ( kc , 'checkRolloutStatus' )
18
20
await manifestStabilityUtils . checkManifestStability (
19
21
kc ,
20
22
resources ,
21
- resourceType
23
+ ResourceTypeFleet
22
24
)
23
25
24
26
expect ( checkRolloutStatusSpy ) . not . toHaveBeenCalled ( )
25
27
expect ( spy ) . toHaveReturned ( )
26
28
} )
29
+
30
+ it ( 'should run fully if the resource type is managedCluster' , async ( ) => {
31
+ const spy = jest . spyOn ( manifestStabilityUtils , 'checkManifestStability' )
32
+ const checkRolloutStatusSpy = jest
33
+ . spyOn ( kc , 'checkRolloutStatus' )
34
+ . mockImplementation ( ( ) => {
35
+ return new Promise < ExecOutput > ( ( resolve , reject ) => {
36
+ resolve ( {
37
+ exitCode : 0 ,
38
+ stderr : '' ,
39
+ stdout : ''
40
+ } )
41
+ } )
42
+ } )
43
+ await manifestStabilityUtils . checkManifestStability (
44
+ kc ,
45
+ resources ,
46
+ ResourceTypeManagedCluster
47
+ )
48
+
49
+ expect ( checkRolloutStatusSpy ) . toHaveBeenCalled ( )
50
+ expect ( spy ) . toHaveReturned ( )
51
+ } )
27
52
} )
0 commit comments