1 | import { SoftwareEnvironment, SoftwarePackage } from '@stencila/schema'
|
2 |
|
3 | import DockerGenerator from '../src/DockerGenerator'
|
4 | import MockUrlFetcher from './MockUrlFetcher'
|
5 |
|
6 | const urlFetcher = new MockUrlFetcher()
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | test('generate:empty', async () => {
|
13 | const environ = new SoftwareEnvironment()
|
14 | const generator = new DockerGenerator(urlFetcher, environ)
|
15 | expect(await generator.generate(false)).toEqual(`FROM ubuntu:18.04
|
16 |
|
17 | RUN useradd --create-home --uid 1001 -s /bin/bash dockteruser
|
18 | WORKDIR /home/dockteruser
|
19 |
|
20 | USER dockteruser
|
21 | `)
|
22 | })
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | test('generate:packages', async () => {
|
29 | const pkg0 = new SoftwarePackage()
|
30 | pkg0.name = 'libxml2-dev'
|
31 | pkg0.runtimePlatform = 'deb'
|
32 |
|
33 | const pkg1 = new SoftwarePackage()
|
34 | pkg1.name = 'xml2'
|
35 | pkg1.runtimePlatform = 'R'
|
36 | pkg1.softwareRequirements = [pkg0]
|
37 |
|
38 | const pkg2 = new SoftwarePackage()
|
39 | pkg2.name = 'bokeh'
|
40 | pkg2.runtimePlatform = 'Python'
|
41 | pkg2.softwareRequirements = []
|
42 |
|
43 | const environ = new SoftwareEnvironment()
|
44 | environ.datePublished = '2017-01-01'
|
45 | environ.softwareRequirements = [pkg1, pkg2]
|
46 |
|
47 | const generator = new DockerGenerator(urlFetcher, environ)
|
48 | expect(generator.aptPackages('18.04')).toEqual(['libxml2-dev', 'python3', 'python3-pip', 'r-base'])
|
49 | })
|