|
1 | 1 | 'use strict';
|
2 | 2 |
|
| 3 | +process.env.WITHOUT_CONFIG_CACHE=true; |
| 4 | + |
3 | 5 | const fs = require('fs');
|
4 | 6 | const path = require('path');
|
5 | 7 | const plugin = require('../plugins');
|
@@ -46,46 +48,43 @@ exports.plugin = {
|
46 | 48 | }
|
47 | 49 | }
|
48 | 50 |
|
49 |
| -const toPath = path.join('config', `${piName }.timeout`); |
50 |
| - |
51 |
| -const toVals = [ '0', '3', '60', 'apple']; |
52 |
| -function getVal () { |
53 |
| - return toVals.shift(); |
54 |
| -} |
| 51 | +const toPath = path.join('config', `${piName}.timeout`); |
55 | 52 |
|
56 | 53 | exports.get_timeout = {
|
57 |
| - setUp (done) { |
58 |
| - process.env.WITHOUT_CONFIG_CACHE=true; |
59 |
| - this.to = getVal(); |
60 |
| - const self = this; |
61 |
| - fs.writeFile(toPath, this.to, () => { |
62 |
| - self.plugin = new plugin.Plugin(piName); |
63 |
| - done(); |
64 |
| - }); |
65 |
| - }, |
66 | 54 | tearDown : done => {
|
67 |
| - delete process.env.WITHOUT_CONFIG_CACHE; |
68 | 55 | fs.unlink(toPath, done);
|
69 | 56 | },
|
70 | 57 | '0s' (test) {
|
71 | 58 | test.expect(1);
|
72 |
| - test.equal( this.plugin.timeout, this.to ); |
73 |
| - test.done(); |
| 59 | + fs.writeFile(toPath, '0', () => { |
| 60 | + this.plugin = new plugin.Plugin(piName); |
| 61 | + test.equal( this.plugin.timeout, 0 ); |
| 62 | + test.done(); |
| 63 | + }) |
74 | 64 | },
|
75 | 65 | '3s' (test) {
|
76 | 66 | test.expect(1);
|
77 |
| - test.equal( this.plugin.timeout, this.to ); |
78 |
| - test.done(); |
| 67 | + fs.writeFile(toPath, '3', () => { |
| 68 | + this.plugin = new plugin.Plugin(piName); |
| 69 | + test.equal( this.plugin.timeout, 3 ); |
| 70 | + test.done(); |
| 71 | + }) |
79 | 72 | },
|
80 | 73 | '60s' (test) {
|
81 | 74 | test.expect(1);
|
82 |
| - test.equal( this.plugin.timeout, this.to ); |
83 |
| - test.done(); |
| 75 | + fs.writeFile(toPath, '60', () => { |
| 76 | + this.plugin = new plugin.Plugin(piName); |
| 77 | + test.equal( this.plugin.timeout, 60 ); |
| 78 | + test.done(); |
| 79 | + }) |
84 | 80 | },
|
85 |
| - '30s default (overrides NaN apple)' (test) { |
| 81 | + '30s default (overrides NaN)' (test) { |
86 | 82 | test.expect(1);
|
87 |
| - test.equal( this.plugin.timeout, 30 ); |
88 |
| - test.done(); |
| 83 | + fs.writeFile(toPath, 'apple', () => { |
| 84 | + this.plugin = new plugin.Plugin(piName); |
| 85 | + test.equal( this.plugin.timeout, 30 ); |
| 86 | + test.done(); |
| 87 | + }) |
89 | 88 | },
|
90 | 89 | }
|
91 | 90 |
|
|
0 commit comments