-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-cli.test.ts
More file actions
110 lines (104 loc) · 3.25 KB
/
Copy pathgithub-cli.test.ts
File metadata and controls
110 lines (104 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import {PluginTester, testSpawn} from '@codifycli/plugin-test';
import * as path from 'node:path';
import {beforeAll, describe, expect, it} from 'vitest';
import {SpawnStatus} from "@codifycli/schemas";
describe('GitHub CLI integration tests', async () => {
const pluginPath = path.resolve('./src/index.ts');
beforeAll(async () => {
const result = await testSpawn('which gh');
if (result.status === SpawnStatus.SUCCESS) {
await PluginTester.uninstall(pluginPath, [{type: 'github-cli'}]);
}
}, 60_000);
it('Can install and uninstall GitHub CLI', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[{ type: 'github-cli' }],
{
validateApply: async () => {
const result = await testSpawn('which gh');
expect(result.status).toBe(SpawnStatus.SUCCESS);
},
validateDestroy: async () => {
const result = await testSpawn('which gh');
expect(result.status).toBe(SpawnStatus.ERROR);
},
}
);
});
it('Can install GitHub CLI and configure git_protocol', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[
{
type: 'github-cli',
gitProtocol: 'https',
prompt: 'enabled',
},
],
{
validateApply: async () => {
const result = await testSpawn('gh config get git_protocol');
expect(result.status).toBe(SpawnStatus.SUCCESS);
expect(result.data.trim()).toBe('https');
},
testModify: {
modifiedConfigs: [
{
type: 'github-cli',
gitProtocol: 'ssh',
prompt: 'enabled',
},
],
validateModify: async () => {
const result = await testSpawn('gh config get git_protocol');
expect(result.data.trim()).toBe('ssh');
},
},
validateDestroy: async () => {
const result = await testSpawn('which gh');
expect(result.status).toBe(SpawnStatus.ERROR);
},
}
);
});
it('Can create and delete a gh alias', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[
{ type: 'github-cli' },
{
type: 'github-cli-alias',
alias: 'codify-test-alias',
expansion: 'pr list',
},
],
{
validateApply: async () => {
const result = await testSpawn('gh alias list');
expect(result.status).toBe(SpawnStatus.SUCCESS);
expect(result.data).toContain('codify-test-alias');
},
testModify: {
modifiedConfigs: [
{
type: 'github-cli-alias',
alias: 'codify-test-alias',
expansion: 'pr status',
},
],
validateModify: async () => {
const result = await testSpawn('gh alias list');
expect(result.data).toContain('pr status');
},
},
validateDestroy: async () => {
const result = await testSpawn('gh alias list');
if (result.status === SpawnStatus.SUCCESS) {
expect(result.data).not.toContain('codify-test-alias');
}
},
}
);
});
});