-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
78 lines (71 loc) · 1.83 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
var test = require('tap').test;
var ND = require('./');
var nd = new ND(process.env.DOCKER_SOCK || '/var/run/docker.sock');
var redisContainer = 'myRedis' + (new Date()).getTime();
test('pulling an image', function(t) {
t.plan(3);
nd
.pull('hello-world')
.then(function(img) {
t.equal(img.type, 'image', 'got an image back');
t.equal(img.name, 'hello-world', 'name is present');
t.notOk(/_/.test(JSON.stringify(img)), 'no underscores');
})
.catch(function(err) {
t.notOk(!!err, err.message);
});
});
test('pulling an image with a specific tag', function(t) {
t.plan(2);
var tag = 'latest';
nd
.pull('hello-world:' + tag)
.then(function(img) {
t.equal(img.tag, tag, 'tag pulled');
t.equal(img._reference, 'hello-world:' + tag, 'reference is right');
})
.catch(function(err) {
t.notOk(!!err, err.message);
});
});
test('inspecting an image', function(t) {
t.plan(2);
nd
.image('hello-world')
.then(function(img) {
t.equal(img.Architecture, 'amd64', 'arch');
t.equal(img.VirtualSize, '910 B', 'virtual size');
})
.catch(function(err) {
t.notOk(!!err, err.message);
});
});
test('image inspection & history', function(t) {
t.plan(1);
nd
.image('hello-world')
.then(function(img) {
return img.history();
})
.then(function(history) {
t.notEqual(history.length, 0, 'there is a history');
})
.catch(function(err) {
t.notOk(!!err, err.message);
});
});
test('runs & inspects a container', function(t) {
t.plan(1);
nd
.pull('redis')
.then(function() {
return nd.run(redisContainer, 'redis');
})
.then(function(myRedis) {
t.equal(myRedis.type, 'container');
})
.catch(function(err) {
t.notOk(!!err, err.message);
});
});