isActionRepo()

This commit is contained in:
Edwin Sirko
2024-01-26 13:07:57 -05:00
parent 55e582b23e
commit 4ed2e10e92
3 changed files with 44 additions and 0 deletions
+28
View File
@@ -1,5 +1,6 @@
import * as fsHelper from '../src/fs-helper'
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
import { execSync } from 'child_process'
@@ -131,6 +132,33 @@ describe('isDirectory', () => {
})
})
describe('isActionRepo', () => {
let stagingDir: string
beforeEach(() => {
stagingDir = fsHelper.createTempDir()
})
afterEach(() => {
fs.rmSync(stagingDir, { recursive: true })
})
it('returns true if action.yml exists at the root', () => {
fs.writeFileSync(path.join(stagingDir, `action.yml`), fileContent)
expect(fsHelper.isActionRepo(stagingDir)).toEqual(true)
})
it('returns true if action.yaml exists at the root', () => {
fs.writeFileSync(path.join(stagingDir, `action.yaml`), fileContent)
expect(fsHelper.isActionRepo(stagingDir)).toEqual(true)
})
it('returns false if action.y(a)ml doesn\'t exist at the root', () => {
fs.writeFileSync(path.join(stagingDir, `action.yaaml`), fileContent)
expect(fsHelper.isActionRepo(stagingDir)).toEqual(false)
})
})
describe('readFileContents', () => {
let dir: string