Skip to content

Commit 5a0813f

Browse files
committed
chore: tidy up some tests and remove devcontainer
1 parent 70d9b6b commit 5a0813f

File tree

5 files changed

+27
-32
lines changed

5 files changed

+27
-32
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

__tests__/git.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jest.mock('@actions/io', () => ({
2828
}))
2929

3030
jest.mock('../src/execute', () => ({
31-
// eslint-disable-next-line @typescript-eslint/naming-convention
3231
__esModule: true,
3332
execute: jest.fn(() => ({stdout: '', stderr: ''}))
3433
}))

__tests__/worktree.error.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {execute} from '../src/execute'
33
import {generateWorktree} from '../src/worktree'
44

55
jest.mock('../src/execute', () => ({
6-
// eslint-disable-next-line @typescript-eslint/naming-convention
76
__esModule: true,
87
execute: jest.fn(() => ({stdout: '', stderr: ''}))
98
}))

__tests__/worktree.test.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ jest.mock('@actions/core', () => ({
1414
}))
1515

1616
/*
17-
Test generateWorktree against a known git repository.
18-
The upstream repository `origin` is set up once for the test suite,
19-
and for each test run, a new clone is created.
20-
21-
See workstree.error.test.ts for testing mocked errors from git.*/
17+
Test generateWorktree against a known git repository.
18+
The upstream repository `origin` is set up once for the test suite,
19+
and for each test run, a new clone is created.
2220
21+
See workstree.error.test.ts for testing mocked errors from git.
22+
*/
2323
describe('generateWorktree', () => {
2424
let tempdir: string | null = null
2525
let clonedir: string | null = null
26+
2627
beforeAll(async () => {
2728
// Set up origin repository
2829
const silent = true
@@ -50,6 +51,7 @@ describe('generateWorktree', () => {
5051
await execute('git add .', origin, silent)
5152
await execute('git commit -mgh1', origin, silent)
5253
})
54+
5355
beforeEach(async () => {
5456
// Clone origin to our workspace for each test
5557
const silent = true
@@ -65,17 +67,19 @@ describe('generateWorktree', () => {
6567
await execute('git fetch --depth=1 origin main', clonedir, silent)
6668
await execute('git checkout main', clonedir, silent)
6769
})
70+
6871
afterEach(async () => {
6972
// Tear down workspace
7073
await rmRF(clonedir as string)
7174
})
75+
7276
afterAll(async () => {
7377
// Tear down origin repository
7478
if (tempdir) {
7579
await rmRF(tempdir)
76-
// console.log(tempdir)
7780
}
7881
})
82+
7983
describe('with existing branch and new commits', () => {
8084
it('should check out the latest commit', async () => {
8185
const workspace = clonedir as string
@@ -92,24 +96,29 @@ describe('generateWorktree', () => {
9296
'worktree',
9397
true
9498
)
99+
95100
const dirEntries = await fs.promises.readdir(
96101
path.join(workspace, 'worktree')
97102
)
103+
98104
expect(dirEntries.sort((a, b) => a.localeCompare(b))).toEqual([
99105
'.git',
100106
'gh1'
101107
])
108+
102109
const commitMessages = await execute(
103110
'git log --format=%s',
104111
path.join(workspace, 'worktree'),
105112
true
106113
)
114+
107115
expect(commitMessages.stdout).toBe('gh1')
108116
})
109117
})
110118
describe('with missing branch and new commits', () => {
111119
it('should create initial commit', async () => {
112120
const workspace = clonedir as string
121+
113122
await generateWorktree(
114123
{
115124
hostname: 'github.com',
@@ -123,21 +132,26 @@ describe('generateWorktree', () => {
123132
'worktree',
124133
false
125134
)
135+
126136
const dirEntries = await fs.promises.readdir(
127137
path.join(workspace, 'worktree')
128138
)
139+
129140
expect(dirEntries).toEqual(['.git'])
141+
130142
const commitMessages = await execute(
131143
'git log --format=%s',
132144
path.join(workspace, 'worktree'),
133145
true
134146
)
147+
135148
expect(commitMessages.stdout).toBe('Initial no-pages commit')
136149
})
137150
})
138151
describe('with existing branch and singleCommit', () => {
139152
it('should check out the latest commit', async () => {
140153
const workspace = clonedir as string
154+
141155
await generateWorktree(
142156
{
143157
hostname: 'github.com',
@@ -151,13 +165,16 @@ describe('generateWorktree', () => {
151165
'worktree',
152166
true
153167
)
168+
154169
const dirEntries = await fs.promises.readdir(
155170
path.join(workspace, 'worktree')
156171
)
172+
157173
expect(dirEntries.sort((a, b) => a.localeCompare(b))).toEqual([
158174
'.git',
159175
'gh1'
160176
])
177+
161178
expect(async () => {
162179
await execute(
163180
'git log --format=%s',
@@ -170,6 +187,7 @@ describe('generateWorktree', () => {
170187
describe('with missing branch and singleCommit', () => {
171188
it('should create initial commit', async () => {
172189
const workspace = clonedir as string
190+
173191
await generateWorktree(
174192
{
175193
hostname: 'github.com',
@@ -183,10 +201,13 @@ describe('generateWorktree', () => {
183201
'worktree',
184202
false
185203
)
204+
186205
const dirEntries = await fs.promises.readdir(
187206
path.join(workspace, 'worktree')
188207
)
208+
189209
expect(dirEntries).toEqual(['.git'])
210+
190211
expect(async () => {
191212
await execute(
192213
'git log --format=%s',

0 commit comments

Comments
 (0)