|
1 | 1 | describe('configure-docker module test suite', () => {
|
| 2 | + let download; |
2 | 3 | let configureEnvironment;
|
3 | 4 | let logExecSync;
|
4 | 5 | beforeEach(() => {
|
5 | 6 | jest.resetModules();
|
6 | 7 | jest.mock('../exec');
|
7 | 8 | jest.mock('../download');
|
| 9 | + download = require('../download'); |
8 | 10 | configureEnvironment = require('../configure-environment');
|
9 | 11 | logExecSync = require('../exec').logExecSync;
|
10 | 12 | });
|
11 |
| - test('configureEnvironment, should run all configuration commands', () => { |
12 |
| - // Given |
13 |
| - logExecSync.mockImplementation(() => {}); |
14 |
| - // When |
15 |
| - configureEnvironment(); |
16 |
| - // Then |
17 |
| - expect(logExecSync).toHaveBeenCalledTimes(2); |
18 |
| - }); |
19 |
| - test('configureEnvironment with docker driver, should run all configuration commands', () => { |
20 |
| - // Given |
21 |
| - logExecSync.mockImplementation(() => {}); |
22 |
| - // When |
23 |
| - configureEnvironment({driver: 'docker'}); |
24 |
| - // Then |
25 |
| - expect(logExecSync).toHaveBeenCalledTimes(3); |
| 13 | + describe('configureEnvironment', () => { |
| 14 | + beforeEach(() => { |
| 15 | + logExecSync.mockImplementation(() => {}); |
| 16 | + }); |
| 17 | + describe('with driver=docker', () => { |
| 18 | + beforeEach(() => { |
| 19 | + configureEnvironment({driver: 'docker'}); |
| 20 | + }); |
| 21 | + test('installs conntrack', () => { |
| 22 | + expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); |
| 23 | + expect(logExecSync).toHaveBeenCalledWith( |
| 24 | + 'sudo apt-get install -y conntrack' |
| 25 | + ); |
| 26 | + }); |
| 27 | + test('waits for docker to be ready', () => { |
| 28 | + expect(logExecSync).toHaveBeenCalledWith( |
| 29 | + "docker version -f '{{.Server.Version}} - {{.Client.Version}}'" |
| 30 | + ); |
| 31 | + }); |
| 32 | + test('doesn\t install cni plugins', () => { |
| 33 | + expect(download.installCniPlugins).not.toHaveBeenCalled(); |
| 34 | + }); |
| 35 | + }); |
| 36 | + describe('with driver=undefined', () => { |
| 37 | + beforeEach(() => { |
| 38 | + configureEnvironment(); |
| 39 | + }); |
| 40 | + test('installs conntrack', () => { |
| 41 | + expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); |
| 42 | + expect(logExecSync).toHaveBeenCalledWith( |
| 43 | + 'sudo apt-get install -y conntrack' |
| 44 | + ); |
| 45 | + }); |
| 46 | + test('installs cni plugins', () => { |
| 47 | + expect(download.installCniPlugins).toHaveBeenCalledTimes(1); |
| 48 | + }); |
| 49 | + test('installs crictl', () => { |
| 50 | + expect(download.installCriCtl).toHaveBeenCalledTimes(1); |
| 51 | + }); |
| 52 | + test('installs cri-dockerd', () => { |
| 53 | + expect(download.installCriDockerd).toHaveBeenCalledTimes(1); |
| 54 | + }); |
| 55 | + }); |
| 56 | + describe('with driver=none', () => { |
| 57 | + beforeEach(() => { |
| 58 | + configureEnvironment({driver: 'none'}); |
| 59 | + }); |
| 60 | + test('installs conntrack', () => { |
| 61 | + expect(logExecSync).toHaveBeenCalledWith('sudo apt update -y'); |
| 62 | + expect(logExecSync).toHaveBeenCalledWith( |
| 63 | + 'sudo apt-get install -y conntrack' |
| 64 | + ); |
| 65 | + }); |
| 66 | + test('installs cni plugins', () => { |
| 67 | + expect(download.installCniPlugins).toHaveBeenCalledTimes(1); |
| 68 | + }); |
| 69 | + test('installs crictl', () => { |
| 70 | + expect(download.installCriCtl).toHaveBeenCalledTimes(1); |
| 71 | + }); |
| 72 | + test('installs cri-dockerd', () => { |
| 73 | + expect(download.installCriDockerd).toHaveBeenCalledTimes(1); |
| 74 | + }); |
| 75 | + }); |
26 | 76 | });
|
27 | 77 | });
|
0 commit comments