@@ -46,11 +46,41 @@ suite('release workflow lifter', () => {
46
46
assert . calledWith ( scaffolder . default , { projectRoot, nodeVersion} ) ;
47
47
} ) ;
48
48
49
- test ( 'that the scaffolder is not called when a modern release workflow already exists ' , async ( ) => {
49
+ test ( 'that the scaffolder is re-run when the release workflow does not restrict permissions ' , async ( ) => {
50
50
core . fileExists . withArgs ( pathToReleaseWorkflowFile ) . resolves ( true ) ;
51
51
fs . readFile . withArgs ( pathToReleaseWorkflowFile , 'utf-8' ) . resolves ( existingWorkflowContents ) ;
52
52
jsYaml . load . withArgs ( existingWorkflowContents ) . returns ( { on : { } } ) ;
53
53
54
+ await lift ( { projectRoot, nodeVersion} ) ;
55
+
56
+ assert . calledWith ( scaffolder . default , { projectRoot, nodeVersion} ) ;
57
+ } ) ;
58
+
59
+ test ( 'that the scaffolder is re-run when the release workflow does not restrict permissions enough' , async ( ) => {
60
+ core . fileExists . withArgs ( pathToReleaseWorkflowFile ) . resolves ( true ) ;
61
+ fs . readFile . withArgs ( pathToReleaseWorkflowFile , 'utf-8' ) . resolves ( existingWorkflowContents ) ;
62
+ jsYaml . load . withArgs ( existingWorkflowContents ) . returns ( { on : { } , permissions : any . simpleObject ( ) } ) ;
63
+
64
+ await lift ( { projectRoot, nodeVersion} ) ;
65
+
66
+ assert . calledWith ( scaffolder . default , { projectRoot, nodeVersion} ) ;
67
+ } ) ;
68
+
69
+ test ( 'that the scaffolder is re-run when the workflow does not properly restrict contents permission' , async ( ) => {
70
+ core . fileExists . withArgs ( pathToReleaseWorkflowFile ) . resolves ( true ) ;
71
+ fs . readFile . withArgs ( pathToReleaseWorkflowFile , 'utf-8' ) . resolves ( existingWorkflowContents ) ;
72
+ jsYaml . load . withArgs ( existingWorkflowContents ) . returns ( { on : { } , permissions : { contents : 'write' } } ) ;
73
+
74
+ await lift ( { projectRoot, nodeVersion} ) ;
75
+
76
+ assert . calledWith ( scaffolder . default , { projectRoot, nodeVersion} ) ;
77
+ } ) ;
78
+
79
+ test ( 'that the scaffolder is not called when a modern release workflow already exists' , async ( ) => {
80
+ core . fileExists . withArgs ( pathToReleaseWorkflowFile ) . resolves ( true ) ;
81
+ fs . readFile . withArgs ( pathToReleaseWorkflowFile , 'utf-8' ) . resolves ( existingWorkflowContents ) ;
82
+ jsYaml . load . withArgs ( existingWorkflowContents ) . returns ( { on : { } , permissions : { contents : 'read' } } ) ;
83
+
54
84
await lift ( { projectRoot} ) ;
55
85
56
86
assert . notCalled ( scaffolder . default ) ;
0 commit comments