Initial Commit
Some checks failed
Continuous Integration / GitHub Actions Test (push) Successful in 23s
CodeQL / Analyze (TypeScript) (push) Failing after 5m27s
Check Transpiled JavaScript / Check dist/ (push) Has been cancelled
Continuous Integration / TypeScript Tests (push) Has been cancelled
Lint Codebase / Lint Codebase (push) Has been cancelled

This commit is contained in:
2024-11-05 23:08:13 +13:00
commit 42fb744b4f
38 changed files with 38124 additions and 0 deletions

17
__tests__/index.test.ts Normal file
View File

@@ -0,0 +1,17 @@
/**
* Unit tests for the action's entrypoint, src/index.ts
*/
import * as main from '../src/main'
// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
describe('index', () => {
it('calls run when imported', () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../src/index')
expect(runMock).toHaveBeenCalled()
})
})

50
__tests__/util.test.ts Normal file
View File

@@ -0,0 +1,50 @@
import * as util from '../src/util'
describe('getPlatformExtension', () => {
it('should return "zip" for Windows', () => {
Object.defineProperty(process, 'platform', { value: 'win32' })
expect(util.getPlatformExtension()).toBe('zip')
})
it('should return "tgz" for non-Windows platforms', () => {
Object.defineProperty(process, 'platform', { value: 'linux' })
expect(util.getPlatformExtension()).toBe('tgz')
Object.defineProperty(process, 'platform', { value: 'darwin' })
expect(util.getPlatformExtension()).toBe('tgz')
})
})
describe('getConanArchitecture', () => {
it('should return "x86_64" for x64 architecture', () => {
Object.defineProperty(process, 'arch', { value: 'x64' })
expect(util.getConanArchitecture()).toBe('x86_64')
})
it('should return "i686" for ia32 architecture', () => {
Object.defineProperty(process, 'arch', { value: 'ia32' })
expect(util.getConanArchitecture()).toBe('i686')
})
it('should return the same architecture string for other architectures', () => {
Object.defineProperty(process, 'arch', { value: 'arm64' })
expect(util.getConanArchitecture()).toBe('arm64')
})
})
describe('getConanPlatform', () => {
it('should return "windows" for Windows', () => {
Object.defineProperty(process, 'platform', { value: 'win32' })
expect(util.getConanPlatform()).toBe('windows')
})
it('should return "macos" for macOS', () => {
Object.defineProperty(process, 'platform', { value: 'darwin' })
expect(util.getConanPlatform()).toBe('macos')
})
it('should return "linux" for non-Windows and non-macOS platforms', () => {
Object.defineProperty(process, 'platform', { value: 'linux' })
expect(util.getConanPlatform()).toBe('linux')
})
})