UNPKG

1.23 kBJavaScriptView Raw
1import test from 'ava'
2import fs from 'fs'
3import { Docker } from '../lib/docker'
4import { Volume } from '../lib/volume'
5
6const socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock'
7const isSocket = fs.existsSync(socket) ? fs.statSync(socket).isSocket() : false
8const docker = isSocket
9 ? new Docker()
10 : new Docker({ socketPath: socket })
11
12test('list', async t => {
13 const volumes = await docker.volume.list()
14 t.is(volumes.constructor, Array)
15})
16
17test('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
31test('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
45test.after('prune', async t => {
46 t.truthy(await docker.volume.prune())
47})