UNPKG

2.57 kBJavaScriptView Raw
1/**
2 * Test case for apemanDply.
3 * Runs with mocha.
4 */
5'use strict'
6
7const apemanDply = require('../lib/apeman_dply.js')
8const apemanInfr = require('apeman-infr')
9const injectmock = require('injectmock')
10const assert = require('assert')
11
12describe('apeman-dply', function () {
13 this.timeout(32000)
14
15 let Apemanfile = require.resolve('../doc/mocks/mock-project/Apemanfile')
16
17 before((done) => {
18 done()
19 })
20
21 after((done) => {
22 injectmock.restoreAll()
23 done()
24 })
25
26 it('Build a infra', (done) => {
27 apemanInfr({
28 configuration: Apemanfile
29 }).then(
30 result => done(),
31 err => {
32 assert.ifError(err)
33 done()
34 }
35 )
36 })
37
38 it('List deploy', (done) => {
39 apemanDply({
40 configuration: Apemanfile,
41 list: true
42 }).then(
43 result => done(),
44 err => {
45 assert.ifError(err)
46 done()
47 }
48 )
49 })
50
51 it('Do deploy', (done) => {
52 apemanDply({
53 configuration: Apemanfile
54 }).then(
55 result => done(),
56 err => {
57 assert.ifError(err)
58 done()
59 }
60 )
61 })
62
63 it('Re deploy', (done) => {
64 apemanDply({
65 rerun: true,
66 force: true,
67 configuration: Apemanfile
68 }).then(
69 result => done(),
70 err => {
71 assert.ifError(err)
72 done()
73 }
74 )
75 })
76
77 it('Exec command ', (done) => {
78 apemanDply({
79 exec: "ls -l",
80 configuration: Apemanfile
81 }).then(
82 result => done(),
83 err => {
84 assert.ifError(err)
85 done()
86 }
87 )
88 })
89
90 it('Open tty', (done) => {
91 apemanDply("hoge", {
92 tty: true,
93 configuration: Apemanfile
94 }).then(
95 terminal => {
96 done()
97 }).catch(err => {
98 assert.ok(!!err)
99 done()
100 })
101 })
102
103 it('Remove deploy', (done) => {
104 apemanDply({
105 configuration: Apemanfile,
106 delete: true,
107 force: true
108 }).then(
109 result => done(),
110 err => {
111 assert.ifError(err)
112 done()
113 }
114 )
115 })
116
117 it('Remove a infra', (done) => {
118 apemanInfr({
119 delete: true,
120 configuration: Apemanfile,
121 force: true
122 }).then(
123 result => done(),
124 err => {
125 assert.ifError(err)
126 done()
127 }
128 )
129 })
130
131 it('Try invalid options', (done) => {
132 apemanDply({
133 rerun: true,
134 delete: true,
135 tty: true,
136 force: true
137 }).then(
138 result => {
139 throw new Error('Invalid result')
140 },
141 err => {
142 assert.ok(!!err)
143 done()
144 }
145 )
146 })
147
148})
149
150/* global describe, before, after, it */