1 | import Docker from 'dockerode'
|
2 |
|
3 | import DockerBuilder from '../src/DockerBuilder'
|
4 | import { fixture } from './test-functions'
|
5 |
|
6 |
|
7 |
|
8 | jest.setTimeout(30 * 60 * 1000)
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | test('build:py-requests-dockter', async () => {
|
15 | const builder = new DockerBuilder()
|
16 | const docker = new Docker()
|
17 |
|
18 |
|
19 | try {
|
20 | await docker.getImage('py-requests-dockter:latest').remove()
|
21 | } catch (error) {
|
22 | if (!error.message.includes('No such image')) throw error
|
23 | }
|
24 |
|
25 |
|
26 | await builder.build(fixture('py-requests-dockter'), 'py-requests-dockter')
|
27 |
|
28 |
|
29 | const latest = docker.getImage('py-requests-dockter:latest')
|
30 | const history = await latest.history()
|
31 | const latestInfo = await latest.inspect()
|
32 | const system = docker.getImage('py-requests-dockter:system')
|
33 | const systemInfo = await system.inspect()
|
34 |
|
35 | expect(history[0].Comment).toEqual('Updated application layer')
|
36 | expect(history[0].Size).toBeGreaterThan(0)
|
37 |
|
38 | })
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | test('build:py-requests-no-dockter', async () => {
|
45 | const builder = new DockerBuilder()
|
46 | const docker = new Docker()
|
47 |
|
48 |
|
49 | try {
|
50 | await docker.getImage('py-requests-no-dockter:latest').remove()
|
51 | } catch (error) {
|
52 | if (!error.message.includes('No such image')) throw error
|
53 | }
|
54 |
|
55 |
|
56 | await builder.build(fixture('py-requests-no-dockter'), 'py-requests-no-dockter')
|
57 |
|
58 |
|
59 | const latest = docker.getImage('py-requests-no-dockter:latest')
|
60 | const history = await latest.history()
|
61 | const latestInfo = await latest.inspect()
|
62 | const system = docker.getImage('py-requests-no-dockter:system')
|
63 | const systemInfo = await system.inspect()
|
64 |
|
65 | expect(history[0].Comment).toEqual('No updates requested')
|
66 | expect(history[0].Size).toEqual(0)
|
67 |
|
68 | })
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | test.skip('build:py-requests-no-dockter', async () => {
|
76 | const builder = new DockerBuilder()
|
77 | let node
|
78 |
|
79 |
|
80 | node = await builder.build('FOO ubuntu\n')
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | node = await builder.build('FROM foobuntoo\n')
|
86 |
|
87 |
|
88 |
|
89 | node = await builder.build('FROM ubuntu\nRUN foo')
|
90 |
|
91 | })
|