-
Notifications
You must be signed in to change notification settings - Fork 27
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
4 changed files
with
85 additions
and
33 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
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
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 |
---|---|---|
@@ -1,27 +1,77 @@ | ||
describe('configure-docker module test suite', () => { | ||
let download; | ||
let configureEnvironment; | ||
let logExecSync; | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
jest.mock('../exec'); | ||
jest.mock('../download'); | ||
download = require('../download'); | ||
configureEnvironment = require('../configure-environment'); | ||
logExecSync = require('../exec').logExecSync; | ||
}); | ||
test('configureEnvironment, should run all configuration commands', () => { | ||
// Given | ||
logExecSync.mockImplementation(() => {}); | ||
// When | ||
configureEnvironment(); | ||
// Then | ||
expect(logExecSync).toHaveBeenCalledTimes(2); | ||
}); | ||
test('configureEnvironment with docker driver, should run all configuration commands', () => { | ||
// Given | ||
logExecSync.mockImplementation(() => {}); | ||
// When | ||
configureEnvironment({driver: 'docker'}); | ||
// Then | ||
expect(logExecSync).toHaveBeenCalledTimes(3); | ||
describe('configureEnvironment', () => { | ||
beforeEach(() => { | ||
logExecSync.mockImplementation(() => {}); | ||
}); | ||
describe('with driver=docker', () => { | ||
beforeEach(() => { | ||
configureEnvironment({driver: 'docker'}); | ||
}); | ||
test('installs conntrack', () => { | ||
expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); | ||
expect(logExecSync).toHaveBeenCalledWith( | ||
'sudo apt-get install -y conntrack' | ||
); | ||
}); | ||
test('waits for docker to be ready', () => { | ||
expect(logExecSync).toHaveBeenCalledWith( | ||
"docker version -f '{{.Server.Version}} - {{.Client.Version}}'" | ||
); | ||
}); | ||
test('doesn\t install cni plugins', () => { | ||
expect(download.installCniPlugins).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
describe('with driver=undefined', () => { | ||
beforeEach(() => { | ||
configureEnvironment(); | ||
}); | ||
test('installs conntrack', () => { | ||
expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); | ||
expect(logExecSync).toHaveBeenCalledWith( | ||
'sudo apt-get install -y conntrack' | ||
); | ||
}); | ||
test('installs cni plugins', () => { | ||
expect(download.installCniPlugins).toHaveBeenCalledTimes(1); | ||
}); | ||
test('installs crictl', () => { | ||
expect(download.installCriCtl).toHaveBeenCalledTimes(1); | ||
}); | ||
test('installs cri-dockerd', () => { | ||
expect(download.installCriDockerd).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
describe('with driver=none', () => { | ||
beforeEach(() => { | ||
configureEnvironment({driver: 'none'}); | ||
}); | ||
test('installs conntrack', () => { | ||
expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); | ||
expect(logExecSync).toHaveBeenCalledWith( | ||
'sudo apt-get install -y conntrack' | ||
); | ||
}); | ||
test('installs cni plugins', () => { | ||
expect(download.installCniPlugins).toHaveBeenCalledTimes(1); | ||
}); | ||
test('installs crictl', () => { | ||
expect(download.installCriCtl).toHaveBeenCalledTimes(1); | ||
}); | ||
test('installs cri-dockerd', () => { | ||
expect(download.installCriDockerd).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); | ||
}); |
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