-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { Command } from '../../command.js'; | ||
import { toDockerExecution } from '../execute.docker.js'; | ||
|
||
describe('DockerExecution', () => { | ||
it('should run hello world', () => { | ||
const cmd = Command.create('echo', { container: 'ubuntu' }).arg('hello world'); | ||
assert.equal(toDockerExecution(cmd).toCommand(), `docker run --rm ubuntu echo hello world`); | ||
}); | ||
|
||
it('should mount folders', () => { | ||
const cmd = Command.create('echo', { container: 'ubuntu' }).arg('hello world'); | ||
cmd.mount('/home'); | ||
|
||
assert.equal(toDockerExecution(cmd).toCommand(), `docker run --rm --volume /home:/home ubuntu echo hello world`); | ||
}); | ||
|
||
it('should not mount duplicate folders', () => { | ||
const cmd = Command.create('echo', { container: 'ubuntu' }).arg('hello world'); | ||
cmd.mount('/home'); | ||
cmd.mount('/home'); | ||
assert.equal(toDockerExecution(cmd).toCommand(), `docker run --rm --volume /home:/home ubuntu echo hello world`); | ||
}); | ||
|
||
it('should mount env vars', () => { | ||
const cmd = Command.create('echo', { container: 'ubuntu' }).arg('hello world'); | ||
cmd.env('AWS_ACCESS_KEY', 'fakeKey'); | ||
assert.equal( | ||
toDockerExecution(cmd).toCommand(), | ||
`docker run --rm --env AWS_ACCESS_KEY=fakeKey ubuntu echo hello world`, | ||
); | ||
}); | ||
|
||
it('should pass through env vars', () => { | ||
const cmd = Command.create('echo', { container: 'ubuntu' }).arg('hello world'); | ||
cmd.env('AWS_ACCESS_KEY'); | ||
assert.equal(toDockerExecution(cmd).toCommand(), `docker run --rm --env AWS_ACCESS_KEY ubuntu echo hello world`); | ||
}); | ||
}); |