@@ -4,7 +4,6 @@ import { GuestType, ScriptType } from '../constants';
44import type { CustomScript } from '../types' ;
55import {
66 buildConfigMapKey ,
7- getNextOrder ,
87 isScriptConfigMap ,
98 scriptsToConfigMapData ,
109 validateScriptName ,
@@ -14,45 +13,39 @@ const createScript = (overrides: Partial<CustomScript> = {}): CustomScript => ({
1413 content : '#!/bin/bash\necho hello' ,
1514 guestType : GuestType . Linux ,
1615 name : 'setup-network' ,
17- order : 10 ,
1816 scriptType : ScriptType . Firstboot ,
1917 ...overrides ,
2018} ) ;
2119
2220describe ( 'buildConfigMapKey' , ( ) => {
23- it ( 'builds a Linux firstboot key' , ( ) => {
21+ it ( 'builds a Linux firstboot key with customer prefix ' , ( ) => {
2422 const script = createScript ( ) ;
25- expect ( buildConfigMapKey ( script ) ) . toBe ( '10_linux_firstboot_setup -network.sh' ) ;
23+ expect ( buildConfigMapKey ( script ) ) . toBe ( '99999_linux_firstboot_setup -network.sh' ) ;
2624 } ) ;
2725
2826 it ( 'builds a Windows firstboot key' , ( ) => {
2927 const script = createScript ( { guestType : GuestType . Windows , scriptType : ScriptType . Firstboot } ) ;
30- expect ( buildConfigMapKey ( script ) ) . toBe ( '10_win_firstboot_setup -network.ps1' ) ;
28+ expect ( buildConfigMapKey ( script ) ) . toBe ( '99999_win_firstboot_setup -network.ps1' ) ;
3129 } ) ;
3230
3331 it ( 'builds a Linux run key' , ( ) => {
3432 const script = createScript ( { scriptType : ScriptType . Run } ) ;
35- expect ( buildConfigMapKey ( script ) ) . toBe ( '10_linux_run_setup-network.sh' ) ;
36- } ) ;
37-
38- it ( 'zero-pads single-digit order numbers' , ( ) => {
39- const script = createScript ( { order : 5 } ) ;
40- expect ( buildConfigMapKey ( script ) ) . toBe ( '05_linux_firstboot_setup-network.sh' ) ;
33+ expect ( buildConfigMapKey ( script ) ) . toBe ( '99999_linux_run_setup-network.sh' ) ;
4134 } ) ;
4235} ) ;
4336
4437describe ( 'scriptsToConfigMapData' , ( ) => {
4538 it ( 'converts multiple scripts to ConfigMap data entries' , ( ) => {
4639 const scripts = [
47- createScript ( { name : 'first' , order : 10 } ) ,
48- createScript ( { name : 'second' , order : 20 , scriptType : ScriptType . Run } ) ,
40+ createScript ( { name : 'first' } ) ,
41+ createScript ( { name : 'second' , scriptType : ScriptType . Run } ) ,
4942 ] ;
5043
5144 const result = scriptsToConfigMapData ( scripts ) ;
5245
5346 expect ( result ) . toEqual ( {
54- '10_linux_firstboot_first .sh' : '#!/bin/bash\necho hello' ,
55- '20_linux_run_second .sh' : '#!/bin/bash\necho hello' ,
47+ '99999_linux_firstboot_first .sh' : '#!/bin/bash\necho hello' ,
48+ '99999_linux_run_second .sh' : '#!/bin/bash\necho hello' ,
5649 } ) ;
5750 } ) ;
5851
@@ -61,17 +54,6 @@ describe('scriptsToConfigMapData', () => {
6154 } ) ;
6255} ) ;
6356
64- describe ( 'getNextOrder' , ( ) => {
65- it ( 'returns 10 for an empty array' , ( ) => {
66- expect ( getNextOrder ( [ ] ) ) . toBe ( 10 ) ;
67- } ) ;
68-
69- it ( 'increments by 10 from the highest order' , ( ) => {
70- const scripts = [ createScript ( { order : 10 } ) , createScript ( { order : 30 } ) ] ;
71- expect ( getNextOrder ( scripts ) ) . toBe ( 40 ) ;
72- } ) ;
73- } ) ;
74-
7557describe ( 'validateScriptName' , ( ) => {
7658 it ( 'returns undefined for a valid name with hyphens' , ( ) => {
7759 expect ( validateScriptName ( 'setup-network' ) ) . toBeUndefined ( ) ;
@@ -96,12 +78,12 @@ describe('validateScriptName', () => {
9678
9779describe ( 'isScriptConfigMap' , ( ) => {
9880 it ( 'returns true for a Linux script key' , ( ) => {
99- const data = { '10_linux_firstboot_setup .sh' : '#!/bin/bash' } ;
81+ const data = { '99999_linux_firstboot_setup .sh' : '#!/bin/bash' } ;
10082 expect ( isScriptConfigMap ( data ) ) . toBe ( true ) ;
10183 } ) ;
10284
10385 it ( 'returns true for a Windows script key' , ( ) => {
104- const data = { '05_win_run_cleanup .ps1' : 'Remove-Item' } ;
86+ const data = { '99999_win_run_cleanup .ps1' : 'Remove-Item' } ;
10587 expect ( isScriptConfigMap ( data ) ) . toBe ( true ) ;
10688 } ) ;
10789
0 commit comments