Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions __tests__/swiftorg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {MODULE_DIR} from '../src/const'

describe('swiftorg sync validation', () => {
const accessSpy = jest.spyOn(fs, 'access')
const rmdirSpy = jest.spyOn(fs, 'rmdir').mockResolvedValue()
const rmSpy = jest.spyOn(fs, 'rm').mockResolvedValue()
const execSpy = jest.spyOn(exec, 'exec')

it('tests latest sync', async () => {
Expand All @@ -14,7 +14,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue(['download'])
const swiftorg = new Swiftorg(true)
await swiftorg.update()
expect(rmdirSpy).not.toHaveBeenCalled()
expect(rmSpy).not.toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(2)
const gitArgs = ['submodule', 'update', '--init', '--recursive', '--remote']
expect(execSpy.mock.calls[1]).toStrictEqual([
Expand All @@ -30,7 +30,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue(['download'])
const swiftorg = new Swiftorg(false)
await swiftorg.update()
expect(rmdirSpy).not.toHaveBeenCalled()
expect(rmSpy).not.toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(2)
const gitArgs = ['submodule', 'update', '--init']
expect(execSpy.mock.calls[1]).toStrictEqual([
Expand All @@ -46,7 +46,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue([])
const swiftorg = new Swiftorg(true)
await swiftorg.update()
expect(rmdirSpy).toHaveBeenCalled()
expect(rmSpy).toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(3)
})

Expand All @@ -56,7 +56,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue([])
const swiftorg = new Swiftorg(false)
await swiftorg.update()
expect(rmdirSpy).toHaveBeenCalled()
expect(rmSpy).toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(4)
})

Expand All @@ -66,7 +66,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue([])
const swiftorg = new Swiftorg(true)
await swiftorg.update()
expect(rmdirSpy).not.toHaveBeenCalled()
expect(rmSpy).not.toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(3)
})

Expand All @@ -76,7 +76,7 @@ describe('swiftorg sync validation', () => {
fs.readdir = jest.fn().mockResolvedValue([])
const swiftorg = new Swiftorg(false)
await swiftorg.update()
expect(rmdirSpy).not.toHaveBeenCalled()
expect(rmSpy).not.toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(4)
})

Expand All @@ -87,7 +87,7 @@ describe('swiftorg sync validation', () => {
fs.readFile = jest.fn().mockResolvedValue('{}')
const swiftorg = new Swiftorg(false)
await swiftorg.update()
expect(rmdirSpy).toHaveBeenCalled()
expect(rmSpy).toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(3)
})

Expand All @@ -98,7 +98,7 @@ describe('swiftorg sync validation', () => {
fs.readFile = jest.fn().mockResolvedValue('{}')
const swiftorg = new Swiftorg(false)
await swiftorg.update()
expect(rmdirSpy).not.toHaveBeenCalled()
expect(rmSpy).not.toHaveBeenCalled()
expect(execSpy).toHaveBeenCalledTimes(3)
})
})
2 changes: 1 addition & 1 deletion src/swiftorg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Swiftorg {
try {
await fs.access(swiftorg)
core.debug(`Removing existing "${swiftorg}" directory`)
await fs.rmdir(swiftorg, {recursive: true})
await fs.rm(swiftorg, {recursive: true})
} catch (error) {
core.debug(`Failed removing "${swiftorg}" with "${error}"`)
}
Expand Down