Skip to content

Commit 69596fa

Browse files
committed
Fixed tests with resolve. Which don't actually throw during the test. Fixed path, macports and homebrew.
1 parent 97c3865 commit 69596fa

12 files changed

Lines changed: 83 additions & 71 deletions

File tree

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ run_dev_task:
1313
- sleep 2000
1414

1515
integration_test_dev_macos_task:
16+
timeout_in: 120m
1617
macos_instance:
1718
image: codify-test-vm
1819
node_modules_cache:

scripts/run-tests.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { glob } from 'glob';
33
import { spawn, spawnSync } from 'node:child_process';
44
import * as inspector from 'node:inspector';
55
import os from 'node:os';
6+
import { OS } from 'codify-schemas';
67

78
const IP_REGEX = /VM was assigned with (.*) IP/;
89

@@ -14,31 +15,31 @@ program
1415
.action(main)
1516
.parse()
1617

17-
async function main(argument: string, operatingSystem: string): Promise<void> {
18+
async function main(argument: string, args: { operatingSystem: string }): Promise<void> {
1819
const debug = isInDebugMode();
1920
if (debug) {
2021
console.log('Running in debug mode!')
2122
}
2223

2324
if (!argument) {
24-
await launchTestAll(debug, operatingSystem)
25+
await launchTestAll(debug, args.operatingSystem)
2526
return process.exit(0);
2627
}
2728

28-
await launchSingleTest(argument, debug, operatingSystem);
29+
await launchSingleTest(argument, debug, args.operatingSystem);
2930
process.exit(0);
3031
}
3132

3233
async function launchTestAll(debug: boolean, operatingSystem: string): Promise<void> {
33-
const image = operatingSystem === 'darwin' ? 'integration_individual_test_macos' : 'integration_individual_test_linux';
34+
const image = operatingSystem === 'darwin' ? 'integration_test_dev_macos' : 'integration_test_dev_linux';
3435

35-
const tests = await glob('./test/**/*.test.ts');
36-
for (const test of tests) {
37-
console.log(`Running test ${test}`)
38-
await run(`cirrus run --lazy-pull ${image} -e FILE_NAME="${test}" ${ debug ? '-o simple' : ''}`, debug, false)
39-
}
36+
// const tests = await glob('./test/**/*.test.ts');
37+
// for (const test of tests) {
38+
// console.log(`Running test ${test}`)
39+
// await run(`cirrus run --lazy-pull ${image} -e FILE_NAME="${test}" ${ debug ? '-o simple' : ''}`, debug, false)
40+
// }
4041

41-
// await run('cirrus run --lazy-pull integration_test_dev -o simple', debug, false);
42+
await run(`cirrus run --lazy-pull ${image} -o simple`, debug, false);
4243
}
4344

4445
async function launchSingleTest(test: string, debug: boolean, operatingSystem: string) {

src/resources/homebrew/casks-parameter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ export class CasksParameter extends StatefulParameter<HomebrewConfig, string[]>
133133
}
134134

135135
private async findConflictsOnMacOs(casks: string[]): Promise<string[]> {
136-
// if (!Utils.isMacOS()) {
136+
if (!Utils.isMacOS()) {
137137
return [];
138-
// }
138+
}
139139

140140

141141
const $ = getPty();

src/resources/macports/macports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { MacportsInstallParameter, PortPackage } from './install-parameter.js';
1010
import schema from './macports-schema.json';
1111

1212
const MACPORTS_DOWNLOAD_LINKS: Record<string, string> = {
13+
'26': 'https://github.com/macports/macports-base/releases/download/v2.11.6/MacPorts-2.11.6-26-Tahoe.pkg',
1314
'15': 'https://github.com/macports/macports-base/releases/download/v2.10.5/MacPorts-2.10.5-15-Sequoia.pkg',
1415
'14': 'https://github.com/macports/macports-base/releases/download/v2.10.5/MacPorts-2.10.5-14-Sonoma.pkg',
1516
'13': 'https://github.com/macports/macports-base/releases/download/v2.10.5/MacPorts-2.10.5-13-Ventura.pkg',

test/asdf/asdf-install.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ describe('Asdf install tests', async () => {
3030
},
3131
], {
3232
validateApply: async () => {
33-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS })
34-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
35-
expect(testSpawn('which golang')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
33+
expect(await testSpawn('which asdf;')).toMatchObject({ status: SpawnStatus.SUCCESS })
34+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.SUCCESS });
35+
expect(await testSpawn('which golang')).toMatchObject({ status: SpawnStatus.SUCCESS });
3636

3737
},
3838
validateDestroy: async () => {
39-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
40-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
41-
expect(testSpawn('which golang')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
39+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
40+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.ERROR });
41+
expect(await testSpawn('which golang')).toMatchObject({ status: SpawnStatus.ERROR });
4242
}
4343
});
4444
})
@@ -57,12 +57,12 @@ describe('Asdf install tests', async () => {
5757
},
5858
], {
5959
validateApply: async () => {
60-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
61-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
60+
expect(await testSpawn('which asdf;')).toMatchObject({ status: SpawnStatus.SUCCESS });
61+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.SUCCESS });
6262
},
6363
validateDestroy: async () => {
64-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
65-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
64+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
65+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.ERROR });
6666
}
6767
});
6868
})

test/asdf/asdf.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ describe('Asdf tests', async () => {
2222
}
2323
], {
2424
validateApply: async () => {
25-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
26-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
25+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.SUCCESS });
26+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.SUCCESS });
2727
},
2828
validateDestroy: async () => {
29-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
30-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
29+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
30+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.ERROR });
3131
}
3232
});
3333
})
@@ -45,12 +45,12 @@ describe('Asdf tests', async () => {
4545
}
4646
], {
4747
validateApply: async () => {
48-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
49-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
48+
expect(await testSpawn('which asdf;')).toMatchObject({ status: SpawnStatus.SUCCESS });
49+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.SUCCESS });
5050
},
5151
validateDestroy: async () => {
52-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
53-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
52+
expect(await testSpawn('which asdf;')).toMatchObject({ status: SpawnStatus.ERROR });
53+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.ERROR });
5454
}
5555
});
5656
})
@@ -84,14 +84,14 @@ describe('Asdf tests', async () => {
8484
}
8585
], {
8686
validateApply: async () => {
87-
expect(testSpawn('which zig;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
88-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
89-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
87+
expect(await testSpawn('which zig')).toMatchObject({ status: SpawnStatus.SUCCESS });
88+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.SUCCESS });
89+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.SUCCESS });
9090
},
9191
validateDestroy: async () => {
92-
expect(testSpawn('which zig;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
93-
expect(testSpawn('which asdf;')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
94-
expect(testSpawn('which node')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
92+
expect(await testSpawn('which zig')).toMatchObject({ status: SpawnStatus.ERROR });
93+
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
94+
expect(await testSpawn('which node')).toMatchObject({ status: SpawnStatus.ERROR });
9595
}
9696
});
9797
})

test/homebrew/custom-install.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ describe('Homebrew custom install integration tests', () => {
1111
type: 'homebrew',
1212
directory: '~/.homebrew',
1313
formulae: [
14-
'jenv',
14+
'sshpass',
1515
],
1616
}], {
1717
validateApply: async () => {
18-
expect(await testSpawn('which jenv')).toMatchObject({ status: SpawnStatus.SUCCESS });
18+
expect(await testSpawn('which sshpass')).toMatchObject({ status: SpawnStatus.SUCCESS });
1919
expect(await testSpawn('which brew')).toMatchObject({ status: SpawnStatus.SUCCESS });
2020
}
2121
})

test/homebrew/default.test.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,33 @@ describe('Homebrew main resource integration tests', () => {
1313
await PluginTester.fullTest(pluginPath, [{
1414
type: 'homebrew',
1515
formulae: [
16-
'apr',
1716
'sshpass'
1817
]
1918
}], {
20-
validateApply: () => {
21-
expect(testSpawn('which apr')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
22-
expect(testSpawn('which sshpass')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
23-
expect(testSpawn('which brew')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
19+
validateApply: async () => {
20+
expect(await testSpawn('which sshpass')).toMatchObject({ status: SpawnStatus.SUCCESS });
21+
expect(await testSpawn('which brew')).toMatchObject({ status: SpawnStatus.SUCCESS });
2422
},
2523
testModify: {
2624
modifiedConfigs: [{
2725
type: 'homebrew',
2826
formulae: [
29-
'libxau',
3027
'sshpass',
31-
'jenv',
3228
'hashicorp/tap/hcp', // Test that it can handle a fully qualified name (tap + name)
3329
],
3430
}],
35-
validateModify: () => {
36-
expect(testSpawn('which libxau')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
37-
expect(testSpawn('which sshpass')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
38-
expect(testSpawn('which jenv')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
39-
expect(testSpawn('which brew')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
40-
expect(testSpawn('which hcp')).resolves.toMatchObject({ status: SpawnStatus.SUCCESS });
31+
validateModify: async () => {
32+
expect(await testSpawn('which sshpass')).toMatchObject({ status: SpawnStatus.SUCCESS });
33+
expect(await testSpawn('which brew')).toMatchObject({ status: SpawnStatus.SUCCESS });
34+
expect(await testSpawn('which hcp')).toMatchObject({ status: SpawnStatus.SUCCESS });
4135
}
4236
},
43-
validateDestroy: () => {
44-
expect(testSpawn('which libxau')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
45-
expect(testSpawn('which sshpass')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
46-
expect(testSpawn('which jenv')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
47-
expect(testSpawn('which hcp')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
48-
expect(testSpawn('which brew')).resolves.toMatchObject({ status: SpawnStatus.ERROR });
37+
validateDestroy: async () => {
38+
expect(await testSpawn('which libxau')).toMatchObject({ status: SpawnStatus.ERROR });
39+
expect(await testSpawn('which sshpass')).toMatchObject({ status: SpawnStatus.ERROR });
40+
expect(await testSpawn('which jenv')).toMatchObject({ status: SpawnStatus.ERROR });
41+
expect(await testSpawn('which hcp')).toMatchObject({ status: SpawnStatus.ERROR });
42+
expect(await testSpawn('which brew')).toMatchObject({ status: SpawnStatus.ERROR });
4943
}
5044
});
5145
});

test/setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { beforeAll, afterAll } from 'vitest';
2+
3+
beforeAll(() => {
4+
5+
})
6+
7+
afterAll(() => {
8+
9+
})

test/shell/path.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ describe('Path resource integration tests', async () => {
103103
validateModify: async (plans) => {
104104
expect(plans[0]).toMatchObject({
105105
operation: ResourceOperation.MODIFY,
106-
parameters: expect.arrayContaining([{
106+
parameters: expect.arrayContaining([expect.objectContaining({
107107
name: 'paths',
108-
previousValue: expect.arrayContaining([tempDir1, tempDir2]),
109-
newValue: expect.arrayContaining([tempDir1, tempDir2, tempDir2, tempDir3]),
108+
previousValue: expect.arrayContaining([tempDir2, tempDir1]),
109+
newValue: expect.arrayContaining([tempDir1, tempDir2, tempDir3, tempDir4]),
110110
operation: ParameterOperation.MODIFY,
111-
}])
111+
})])
112112
})
113113

114114
const { data: path } = await testSpawn('echo $PATH');

0 commit comments

Comments
 (0)