2021-09-01 12:29:50 +10:00
|
|
|
import {install, runCommand} from '../src/install'
|
|
|
|
|
import * as core from '@actions/core'
|
|
|
|
|
|
2022-09-04 09:33:35 +08:00
|
|
|
import {describe, expect, it, test} from '@jest/globals'
|
2020-08-27 20:39:35 +08:00
|
|
|
|
2022-09-04 09:33:35 +08:00
|
|
|
describe('runCommand', () => {
|
|
|
|
|
it('runs a command and returns its stdout', async () => {
|
|
|
|
|
const result = await runCommand('echo foo bar')
|
|
|
|
|
expect(result).toBe('foo bar')
|
|
|
|
|
})
|
2020-08-27 20:39:35 +08:00
|
|
|
})
|
2021-09-01 12:29:50 +10:00
|
|
|
|
2022-09-04 09:33:35 +08:00
|
|
|
describe('install', () => {
|
|
|
|
|
const cases = ['1.29.1', '1.29.2', '2.2.3', 'v2.2.3', 'v2.10.2']
|
|
|
|
|
test.each(cases)('can install version %p', async (version: string) => {
|
|
|
|
|
const commandPath = await install(version)
|
|
|
|
|
core.addPath(commandPath)
|
|
|
|
|
const result = await runCommand('docker-compose version')
|
|
|
|
|
expect(result).toContain(version)
|
|
|
|
|
})
|
2022-12-25 13:58:23 +08:00
|
|
|
it('can install latest version', async () => {
|
|
|
|
|
const commandPath = await install('latest')
|
|
|
|
|
core.addPath(commandPath)
|
|
|
|
|
const result = await runCommand('docker-compose version')
|
|
|
|
|
expect(result).not.toBeFalsy()
|
|
|
|
|
})
|
2021-09-01 12:29:50 +10:00
|
|
|
})
|