1 | import test from 'ava'
|
2 | import fs from 'fs'
|
3 | import { Docker } from '../lib/docker'
|
4 | import { Volume } from '../lib/volume'
|
5 |
|
6 | const socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock'
|
7 | const isSocket = fs.existsSync(socket) ? fs.statSync(socket).isSocket() : false
|
8 | const docker = isSocket
|
9 | ? new Docker()
|
10 | : new Docker({ socketPath: socket })
|
11 |
|
12 | test('list', async t => {
|
13 | const volumes = await docker.volume.list()
|
14 | t.is(volumes.constructor, Array)
|
15 | })
|
16 |
|
17 | test('create', async t => {
|
18 | const volume = await docker.volume.create({
|
19 | "Name": "tardis1",
|
20 | "Labels": {
|
21 | "com.example.some-label": "some-value",
|
22 | "com.example.some-other-label": "some-other-value"
|
23 | },
|
24 | "Driver": "local"
|
25 | })
|
26 |
|
27 | t.is(volume.constructor, Volume)
|
28 | t.notThrows(volume.remove())
|
29 | })
|
30 |
|
31 | test('status', async t => {
|
32 | const volume = await docker.volume.create({
|
33 | "Name": "tardis2",
|
34 | "Labels": {
|
35 | "com.example.some-label": "some-value",
|
36 | "com.example.some-other-label": "some-other-value"
|
37 | },
|
38 | "Driver": "local"
|
39 | })
|
40 | const volumeStatus = await volume.status()
|
41 | t.is(volumeStatus.constructor, Volume)
|
42 | t.notThrows(volume.remove())
|
43 | })
|
44 |
|
45 | test.after('prune', async t => {
|
46 | t.truthy(await docker.volume.prune())
|
47 | })
|