Skip to content

Commit

Permalink
Merge pull request #21 from jhenstridge/update-deps
Browse files Browse the repository at this point in the history
package.json: Upgrade dependencies
  • Loading branch information
jhenstridge authored Jul 12, 2021
2 parents d854a8f + e62d5a4 commit 61deecb
Show file tree
Hide file tree
Showing 5 changed files with 2,691 additions and 2,785 deletions.
60 changes: 35 additions & 25 deletions __tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ test('SnapcraftBuilder.build runs a snap build', async () => {
const ensureSnapcraft = jest
.spyOn(tools, 'ensureSnapcraft')
.mockImplementation(async (channel): Promise<void> => {})
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
}
)
process.env['GITHUB_REPOSITORY'] = 'user/repo'
process.env['GITHUB_RUN_ID'] = '42'

Expand Down Expand Up @@ -88,11 +90,13 @@ test('SnapcraftBuilder.build can disable build info', async () => {
const ensureSnapcraft = jest
.spyOn(tools, 'ensureSnapcraft')
.mockImplementation(async (channel): Promise<void> => {})
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 builder = new build.SnapcraftBuilder({
projectRoot: '.',
Expand Down Expand Up @@ -124,11 +128,13 @@ test('SnapcraftBuilder.build can set the Snapcraft channel', async () => {
const ensureSnapcraft = jest
.spyOn(tools, 'ensureSnapcraft')
.mockImplementation(async (channel): Promise<void> => {})
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 builder = new build.SnapcraftBuilder({
projectRoot: '.',
Expand All @@ -154,11 +160,13 @@ test('SnapcraftBuilder.build can pass additional arguments', async () => {
const ensureSnapcraft = jest
.spyOn(tools, 'ensureSnapcraft')
.mockImplementation(async (channel): Promise<void> => {})
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 builder = new build.SnapcraftBuilder({
projectRoot: '.',
Expand Down Expand Up @@ -188,11 +196,13 @@ test('SnapcraftBuilder.build can pass UA token', async () => {
const ensureSnapcraft = jest
.spyOn(tools, 'ensureSnapcraft')
.mockImplementation(async (channel): Promise<void> => {})
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 builder = new build.SnapcraftBuilder({
projectRoot: '.',
Expand Down
214 changes: 130 additions & 84 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ afterEach(() => {
test('ensureSnapd installs snapd if needed', async () => {
expect.assertions(4)

const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
throw new Error('not found')
}
)
const statMock = jest.spyOn(fs.promises, 'stat').mockImplementation(
async (filename: fs.PathLike): Promise<fs.Stats> => {
const accessMock = jest
.spyOn(fs.promises, 'access')
.mockImplementation(
async (
filename: fs.PathLike,
mode?: number | undefined
): Promise<void> => {
throw new Error('not found')
}
)
const statMock = jest
.spyOn(fs.promises, 'stat')
.mockImplementation(async (filename: fs.PathLike): Promise<fs.Stats> => {
const s = new fs.Stats()
s.uid = 0
s.gid = 0
return s
}
)
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.ensureSnapd()

Expand Down Expand Up @@ -60,19 +67,21 @@ test('ensureSnapd is a no-op if snapd is installed', async () => {
mode?: number | undefined
): Promise<void> => {}
)
const statMock = jest.spyOn(fs.promises, 'stat').mockImplementation(
async (filename: fs.PathLike): Promise<fs.Stats> => {
const statMock = jest
.spyOn(fs.promises, 'stat')
.mockImplementation(async (filename: fs.PathLike): Promise<fs.Stats> => {
const s = new fs.Stats()
s.uid = 0
s.gid = 0
return s
}
)
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.ensureSnapd()

Expand All @@ -92,19 +101,21 @@ test('ensureSnapd fixes permissions on the root directory', async () => {
mode?: number | undefined
): Promise<void> => {}
)
const statMock = jest.spyOn(fs.promises, 'stat').mockImplementation(
async (filename: fs.PathLike): Promise<fs.Stats> => {
const statMock = jest
.spyOn(fs.promises, 'stat')
.mockImplementation(async (filename: fs.PathLike): Promise<fs.Stats> => {
const s = new fs.Stats()
s.uid = 500
s.gid = 0
return s
}
)
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.ensureSnapd()

Expand All @@ -116,16 +127,23 @@ test('ensureSnapd fixes permissions on the root directory', async () => {
test('ensureLXD installs the snap version of LXD if needed', async () => {
expect.assertions(5)

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.ensureLXD()

Expand Down Expand Up @@ -154,16 +172,23 @@ test('ensureLXD installs the snap version of LXD if needed', async () => {
test('ensureLXD removes the apt version of LXD', async () => {
expect.assertions(2)

const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
return
}
)
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> => {
return
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureLXD()

Expand All @@ -180,19 +205,26 @@ test('ensureLXD removes the apt version of LXD', async () => {
test('ensureLXD still calls "lxd init" if LXD is installed', async () => {
expect.assertions(5)

const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
if (filename === '/snap/bin/lxd') {
return
const accessMock = jest
.spyOn(fs.promises, 'access')
.mockImplementation(
async (
filename: fs.PathLike,
mode?: number | undefined
): Promise<void> => {
if (filename === '/snap/bin/lxd') {
return
}
throw new Error('not found')
}
throw new Error('not found')
}
)
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.ensureLXD()

Expand Down Expand Up @@ -221,16 +253,23 @@ test('ensureLXD still calls "lxd init" if LXD is installed', async () => {
test('ensureSnapcraft installs Snapcraft if needed', async () => {
expect.assertions(2)

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.ensureSnapcraft('edge')

Expand All @@ -248,16 +287,23 @@ test('ensureSnapcraft installs Snapcraft if needed', async () => {
test('ensureSnapcraft refreshes if Snapcraft is installed', async () => {
expect.assertions(2)

const accessMock = jest.spyOn(fs.promises, 'access').mockImplementation(
async (filename: fs.PathLike, mode?: number | undefined): Promise<void> => {
return
}
)
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> => {
return
}
)
const execMock = jest
.spyOn(exec, 'exec')
.mockImplementation(
async (program: string, args?: string[]): Promise<number> => {
return 0
}
)

await tools.ensureSnapcraft('edge')

Expand Down
Loading

0 comments on commit 61deecb

Please sign in to comment.