Skip to content

Commit

Permalink
Merge pull request #15 from diddlesnaps/run-build
Browse files Browse the repository at this point in the history
Ensure npm modules are up to date and run build
  • Loading branch information
Dani Llewellyn authored Nov 22, 2022
2 parents a549534 + 46c35f0 commit 93ebbb5
Show file tree
Hide file tree
Showing 3 changed files with 5,875 additions and 3,720 deletions.
12 changes: 7 additions & 5 deletions __tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ test('SnapcraftBuilder.outputSnap returns the first snap', async () => {
.mockImplementation(
async (path: string): Promise<string[]> => ['one.snap', 'two.snap']
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const warning = jest
.spyOn(core, 'warning')
.mockImplementation((_message: string | Error): void => {})
Expand Down
63 changes: 38 additions & 25 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ test('ensureDockerExperimental is no-op if experimental already set', async () =
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{"experimental": true}`)
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand All @@ -41,16 +43,23 @@ test('ensureDockerExperimental is no-op if experimental already set', async () =
test("ensureDockerExperimental sets experimental mode and restarts docker if configuration file doesn't exist", async () => {
expect.assertions(3)

const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
throw new Error('not found')
}
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const accessMock = jest
.spyOn(fs.promises, 'access')
.mockImplementation(
async (
filename: fs.PathLike,
mode?: number | undefined
): Promise<void> => {
throw new Error('not found')
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down Expand Up @@ -83,11 +92,13 @@ test('ensureDockerExperimental sets experimental mode and restarts docker if not
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{}`)
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down Expand Up @@ -121,11 +132,13 @@ test('ensureDockerExperimental sets experimental mode and restarts docker if exp
async (filename: fs.PathLike | fs.promises.FileHandle): Promise<Buffer> =>
Buffer.from(`{"experimental": false}`)
)
const execMock = jest.spyOn(exec, 'exec').mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureDockerExperimental()

Expand Down
Loading

0 comments on commit 93ebbb5

Please sign in to comment.