ssh-client-wrapper 2.10.2 → 2.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/coverage_report.yml +1 -1
- package/.github/workflows/run_test.yml +3 -2
- package/{docker-compose.yml → compose.yml} +2 -2
- package/eslint.config.mjs +206 -0
- package/lib/fork.js +25 -13
- package/lib/index.js +70 -17
- package/lib/rsyncExec.js +17 -17
- package/lib/sshExec.js +81 -58
- package/lib/util.js +28 -21
- package/package.json +10 -12
- package/run_test_all.sh +3 -12
- package/run_test_local.sh +13 -0
- package/test/getSshOption.js +7 -7
- package/test/interface.js +54 -54
- package/test/rsyncExec.js +72 -72
- package/test/sanityCheck.js +14 -14
- package/test/sshExec.js +63 -61
- package/test/testUtil/testFiles.js +21 -7
- package/test/testUtil/testrc +1 -0
package/test/rsyncExec.js
CHANGED
|
@@ -12,21 +12,21 @@ const exec = util.promisify(require("node:child_process").exec);
|
|
|
12
12
|
* debug.enable("ssh*");
|
|
13
13
|
* (3) insert this line into the end of it()
|
|
14
14
|
* debug.disable();
|
|
15
|
-
|
|
15
|
+
*/
|
|
16
16
|
|
|
17
|
-
process.on("unhandledRejection", console.dir); //
|
|
17
|
+
process.on("unhandledRejection", console.dir); //eslint-disable-line no-console
|
|
18
18
|
Error.traceLimit = 100000;
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
//setup test framework
|
|
21
21
|
const chai = require("chai");
|
|
22
22
|
const { expect } = require("chai");
|
|
23
23
|
chai.use(require("chai-fs"));
|
|
24
24
|
chai.use(require("chai-as-promised"));
|
|
25
25
|
|
|
26
|
-
//
|
|
26
|
+
//testee
|
|
27
27
|
const { checkRsyncVersion, send, recv } = require("../lib/rsyncExec.js");
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
//test helpers
|
|
30
30
|
const { sshExec, disconnect } = require("../lib/sshExec.js");
|
|
31
31
|
const hostInfo = require("./testUtil/hostInfo.js");
|
|
32
32
|
const {
|
|
@@ -42,115 +42,115 @@ const {
|
|
|
42
42
|
remoteFiles
|
|
43
43
|
} = require("./testUtil/testFiles");
|
|
44
44
|
|
|
45
|
-
const formatLsOutput = (array)
|
|
45
|
+
const formatLsOutput = (array)=>{
|
|
46
46
|
const rt = [];
|
|
47
47
|
for (const e of array) {
|
|
48
48
|
rt.push(...e.split("\n"));
|
|
49
49
|
}
|
|
50
|
-
return rt.filter((e)
|
|
50
|
+
return rt.filter((e)=>{
|
|
51
51
|
return e !== "";
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
//
|
|
56
|
-
describe("test checkRsyncVersion", async ()
|
|
55
|
+
//actual test start from here
|
|
56
|
+
describe("test checkRsyncVersion", async ()=>{
|
|
57
57
|
const { major, minor, patch } = await checkRsyncVersion(1);
|
|
58
58
|
const versionString = `${major}.${minor}.${patch}`;
|
|
59
|
-
console.log(`==== test with rsync version ${versionString} ====`); //
|
|
59
|
+
console.log(`==== test with rsync version ${versionString} ====`); //eslint-disable-line no-console
|
|
60
60
|
const { stdout } = await exec("rsync --version |grep 'version'");
|
|
61
61
|
expect(stdout).to.match(new RegExp(versionString));
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe("test rsync exec", function () {
|
|
65
|
-
this.timeout(10000);//
|
|
65
|
+
this.timeout(10000);//eslint-disable-line no-invalid-this
|
|
66
66
|
const rt = [];
|
|
67
|
-
const output = (data)
|
|
67
|
+
const output = (data)=>{
|
|
68
68
|
rt.push(data);
|
|
69
69
|
};
|
|
70
70
|
let remoteHome;
|
|
71
|
-
before(async ()
|
|
72
|
-
await sshExec(hostInfo, "pwd", 0, (data)
|
|
71
|
+
before(async ()=>{
|
|
72
|
+
await sshExec(hostInfo, "pwd", 0, (data)=>{
|
|
73
73
|
remoteHome = data.trim();
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
-
beforeEach(async ()
|
|
76
|
+
beforeEach(async ()=>{
|
|
77
77
|
await clearRemoteTestFiles(hostInfo);
|
|
78
78
|
await createRemoteFiles(hostInfo);
|
|
79
79
|
await clearLocalTestFiles();
|
|
80
80
|
await createLocalFiles();
|
|
81
81
|
rt.splice(0, rt.length);
|
|
82
82
|
});
|
|
83
|
-
after(async ()
|
|
83
|
+
after(async ()=>{
|
|
84
84
|
if (!process.env.TEST_KEEP_FILES) {
|
|
85
85
|
await clearRemoteTestFiles(hostInfo);
|
|
86
86
|
await clearLocalTestFiles();
|
|
87
87
|
}
|
|
88
88
|
await disconnect(hostInfo);
|
|
89
89
|
});
|
|
90
|
-
describe("#send", async ()
|
|
91
|
-
describe("send single file", ()
|
|
92
|
-
it("should accept relative src file and relative dst dir name", async ()
|
|
90
|
+
describe("#send", async ()=>{
|
|
91
|
+
describe("send single file", ()=>{
|
|
92
|
+
it("should accept relative src file and relative dst dir name", async ()=>{
|
|
93
93
|
await send(hostInfo, [localFiles[0]], remoteEmptyDir, [], 0);
|
|
94
94
|
|
|
95
95
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
96
96
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
97
97
|
});
|
|
98
|
-
it("should accept absolute src file and relative dst dir name", async ()
|
|
98
|
+
it("should accept absolute src file and relative dst dir name", async ()=>{
|
|
99
99
|
await send(hostInfo, [path.resolve(localFiles[3])], remoteEmptyDir, [], 0);
|
|
100
100
|
|
|
101
101
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
102
102
|
expect(formatLsOutput(rt)).to.have.members(["piyo"]);
|
|
103
103
|
});
|
|
104
|
-
it("should accept relative src file and absolute dst dir name", async ()
|
|
104
|
+
it("should accept relative src file and absolute dst dir name", async ()=>{
|
|
105
105
|
await send(hostInfo, [localFiles[0]], `${path.posix.join(remoteHome, remoteEmptyDir)}/`, [], 0);
|
|
106
106
|
|
|
107
107
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
108
108
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
109
109
|
});
|
|
110
|
-
it("should accept absolute src file and absolute dst dir name", async ()
|
|
110
|
+
it("should accept absolute src file and absolute dst dir name", async ()=>{
|
|
111
111
|
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
112
112
|
|
|
113
113
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
114
114
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
115
115
|
});
|
|
116
|
-
it("should accept relative src file and relative dst file name", async ()
|
|
116
|
+
it("should accept relative src file and relative dst file name", async ()=>{
|
|
117
117
|
await send(hostInfo, [localFiles[0]], path.posix.join(remoteEmptyDir, "hoge"), [], 0);
|
|
118
118
|
|
|
119
119
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
120
|
-
expect(formatLsOutput(rt.map((e)
|
|
120
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
121
121
|
return path.posix.basename(e);
|
|
122
122
|
}))).to.have.members(["hoge"]);
|
|
123
123
|
});
|
|
124
|
-
it("should accept absolute src file and relative dst file name", async ()
|
|
124
|
+
it("should accept absolute src file and relative dst file name", async ()=>{
|
|
125
125
|
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteEmptyDir, "hoge"), [], 0);
|
|
126
126
|
|
|
127
127
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
128
|
-
expect(formatLsOutput(rt.map((e)
|
|
128
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
129
129
|
return path.posix.basename(e);
|
|
130
130
|
}))).to.have.members(["hoge"]);
|
|
131
131
|
});
|
|
132
|
-
it("should accept relative src file and absolute dst file name", async ()
|
|
132
|
+
it("should accept relative src file and absolute dst file name", async ()=>{
|
|
133
133
|
await send(hostInfo, [localFiles[0]], path.posix.join(remoteHome, remoteEmptyDir, "hoge"), [], 0);
|
|
134
134
|
|
|
135
135
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
136
|
-
expect(formatLsOutput(rt.map((e)
|
|
136
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
137
137
|
return path.posix.basename(e);
|
|
138
138
|
}))).to.have.members(["hoge"]);
|
|
139
139
|
});
|
|
140
|
-
it("should accept absolute src file and absolute dst file name", async ()
|
|
140
|
+
it("should accept absolute src file and absolute dst file name", async ()=>{
|
|
141
141
|
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir, "hoge"), [], 0);
|
|
142
142
|
|
|
143
143
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
144
|
-
expect(formatLsOutput(rt.map((e)
|
|
144
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
145
145
|
return path.posix.basename(e);
|
|
146
146
|
}))).to.have.members(["hoge"]);
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
it("should overwrite existing file", async ()
|
|
149
|
+
it("should overwrite existing file", async ()=>{
|
|
150
150
|
const target = path.posix.join(remoteEmptyDir, "hoge");
|
|
151
151
|
await send(hostInfo, [localFiles[0]], target, [], 0);
|
|
152
152
|
await sshExec(hostInfo, `ls ${target}`, 0, output);
|
|
153
|
-
expect(formatLsOutput(rt.map((e)
|
|
153
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
154
154
|
return path.posix.basename(e);
|
|
155
155
|
}))).to.have.members(["hoge"]);
|
|
156
156
|
rt.splice(0, rt.length);
|
|
@@ -160,7 +160,7 @@ describe("test rsync exec", function () {
|
|
|
160
160
|
await fs.utimes(localFiles[1], time, time);
|
|
161
161
|
await send(hostInfo, [localFiles[1]], target, [], 0);
|
|
162
162
|
await sshExec(hostInfo, `ls ${target}`, 0, output);
|
|
163
|
-
expect(formatLsOutput(rt.map((e)
|
|
163
|
+
expect(formatLsOutput(rt.map((e)=>{
|
|
164
164
|
return path.posix.basename(e);
|
|
165
165
|
}))).to.have.members(["hoge"]);
|
|
166
166
|
|
|
@@ -169,8 +169,8 @@ describe("test rsync exec", function () {
|
|
|
169
169
|
expect(formatLsOutput(rt)).to.have.members(["ARssh_testLocalDir/bar"]);
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
|
-
describe("send directory tree", ()
|
|
173
|
-
it("should accept relative src dirname and relative dst dirname", async ()
|
|
172
|
+
describe("send directory tree", ()=>{
|
|
173
|
+
it("should accept relative src dirname and relative dst dirname", async ()=>{
|
|
174
174
|
await send(hostInfo, [localRoot], remoteEmptyDir, [], 0);
|
|
175
175
|
|
|
176
176
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -180,7 +180,7 @@ describe("test rsync exec", function () {
|
|
|
180
180
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
181
181
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
182
182
|
});
|
|
183
|
-
it("should accept absolute src dirname and relative dst dirname", async ()
|
|
183
|
+
it("should accept absolute src dirname and relative dst dirname", async ()=>{
|
|
184
184
|
await send(hostInfo, [path.resolve(localRoot)], remoteEmptyDir, [], 0);
|
|
185
185
|
|
|
186
186
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -190,7 +190,7 @@ describe("test rsync exec", function () {
|
|
|
190
190
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
191
191
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
192
192
|
});
|
|
193
|
-
it("should accept relative src dirname and absolute dst dirname", async ()
|
|
193
|
+
it("should accept relative src dirname and absolute dst dirname", async ()=>{
|
|
194
194
|
await send(hostInfo, [localRoot], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
195
195
|
|
|
196
196
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -200,7 +200,7 @@ describe("test rsync exec", function () {
|
|
|
200
200
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
201
201
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
202
202
|
});
|
|
203
|
-
it("should accept absolute src dirname and absolute dst dirname", async ()
|
|
203
|
+
it("should accept absolute src dirname and absolute dst dirname", async ()=>{
|
|
204
204
|
await send(hostInfo, [path.resolve(localRoot)], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
205
205
|
|
|
206
206
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -210,8 +210,8 @@ describe("test rsync exec", function () {
|
|
|
210
210
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
211
211
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
212
212
|
});
|
|
213
|
-
//
|
|
214
|
-
it.skip("[not implemented] should send directory tree if only filter matched", async ()
|
|
213
|
+
//only option need special treatment in rsyncExec. it's hard to set in WHEEL
|
|
214
|
+
it.skip("[not implemented] should send directory tree if only filter matched", async ()=>{
|
|
215
215
|
await send(hostInfo, [localRoot], remoteEmptyDir, [`--include=${localRoot}`, `--include=${localRoot}/ba*`, `--include=${localRoot}/hoge/*`, "--exclude=*"], [], 0);
|
|
216
216
|
|
|
217
217
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -221,13 +221,13 @@ describe("test rsync exec", function () {
|
|
|
221
221
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
222
222
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
223
223
|
});
|
|
224
|
-
it("should send directory tree if exclude filter not matched", async ()
|
|
224
|
+
it("should send directory tree if exclude filter not matched", async ()=>{
|
|
225
225
|
await send(hostInfo, [localRoot], remoteEmptyDir, ["--exclude=ba*", "--exclude=hoge*}"], [], 0);
|
|
226
226
|
|
|
227
227
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
228
228
|
expect(formatLsOutput(rt)).to.have.members(["foo", "hoge", "huga"]);
|
|
229
229
|
});
|
|
230
|
-
it.skip("[not implemented] should send directory tree if only filter matched but exclude filter not matched", async ()
|
|
230
|
+
it.skip("[not implemented] should send directory tree if only filter matched but exclude filter not matched", async ()=>{
|
|
231
231
|
await send(hostInfo, [localRoot], remoteEmptyDir, "*/{ba*,hoge/*}", "**/poyo", [], 0);
|
|
232
232
|
|
|
233
233
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
@@ -237,96 +237,96 @@ describe("test rsync exec", function () {
|
|
|
237
237
|
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
238
238
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo"]);
|
|
239
239
|
});
|
|
240
|
-
it("shoud not send empty directory with -m option", async ()
|
|
240
|
+
it("shoud not send empty directory with -m option", async ()=>{
|
|
241
241
|
await send(hostInfo, [localEmptyDir], remoteEmptyDir, ["-m"], [], 0);
|
|
242
242
|
|
|
243
243
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
244
244
|
expect(rt).to.have.lengthOf(0);
|
|
245
245
|
});
|
|
246
|
-
it("should send files which match glob pattern", async ()
|
|
246
|
+
it("should send files which match glob pattern", async ()=>{
|
|
247
247
|
await send(hostInfo, [path.join(localRoot, "b*")], remoteEmptyDir, [], 0);
|
|
248
248
|
|
|
249
249
|
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
250
250
|
expect(formatLsOutput(rt)).to.have.members(["bar", "baz"]);
|
|
251
251
|
});
|
|
252
252
|
});
|
|
253
|
-
describe("error case", ()
|
|
254
|
-
it("should not send directory to existing file path", ()
|
|
253
|
+
describe("error case", ()=>{
|
|
254
|
+
it("should not send directory to existing file path", ()=>{
|
|
255
255
|
return expect(send(hostInfo, [localRoot], path.posix.join(remoteRoot, "foo"), [], 0)).to.be.rejected;
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
|
-
describe("#recv", async ()
|
|
260
|
-
describe("recieve single file", ()
|
|
261
|
-
it("should accept relative src file and relative dst dir name", async ()
|
|
259
|
+
describe("#recv", async ()=>{
|
|
260
|
+
describe("recieve single file", ()=>{
|
|
261
|
+
it("should accept relative src file and relative dst dir name", async ()=>{
|
|
262
262
|
await recv(hostInfo, [remoteFiles[3]], localEmptyDir, [], 0);
|
|
263
263
|
|
|
264
264
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
265
265
|
expect(rt2).to.have.members(["piyo"]);
|
|
266
266
|
});
|
|
267
|
-
it("should accept absolute src file and relative dst dir name", async ()
|
|
267
|
+
it("should accept absolute src file and relative dst dir name", async ()=>{
|
|
268
268
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], localEmptyDir, [], 0);
|
|
269
269
|
|
|
270
270
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
271
271
|
expect(rt2).to.have.members(["piyo"]);
|
|
272
272
|
});
|
|
273
|
-
it("should accept relative src file and absolute dst dir name", async ()
|
|
273
|
+
it("should accept relative src file and absolute dst dir name", async ()=>{
|
|
274
274
|
await recv(hostInfo, [remoteFiles[3]], path.resolve(localEmptyDir), [], 0);
|
|
275
275
|
|
|
276
276
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
277
277
|
expect(rt2).to.have.members(["piyo"]);
|
|
278
278
|
});
|
|
279
|
-
it("should accept absolute src file and absolute dst dir name", async ()
|
|
279
|
+
it("should accept absolute src file and absolute dst dir name", async ()=>{
|
|
280
280
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], path.resolve(localEmptyDir), [], 0);
|
|
281
281
|
|
|
282
282
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
283
283
|
expect(rt2).to.have.members(["piyo"]);
|
|
284
284
|
});
|
|
285
|
-
it("should accept relative src file and relative dst file name", async ()
|
|
285
|
+
it("should accept relative src file and relative dst file name", async ()=>{
|
|
286
286
|
await recv(hostInfo, [remoteFiles[0]], path.join(localEmptyDir, "hoge"), [], 0);
|
|
287
287
|
|
|
288
288
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
289
289
|
expect(rt2).to.have.members(["hoge"]);
|
|
290
290
|
});
|
|
291
|
-
it("should accept absolute src file and relative dst file name", async ()
|
|
291
|
+
it("should accept absolute src file and relative dst file name", async ()=>{
|
|
292
292
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.join(localEmptyDir, "hoge"), [], 0);
|
|
293
293
|
|
|
294
294
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
295
295
|
expect(rt2).to.have.members(["hoge"]);
|
|
296
296
|
});
|
|
297
|
-
it("should accept relative src file and absolute dst file name", async ()
|
|
297
|
+
it("should accept relative src file and absolute dst file name", async ()=>{
|
|
298
298
|
await recv(hostInfo, [remoteFiles[0]], path.resolve(localEmptyDir, "hoge"), [], 0);
|
|
299
299
|
|
|
300
300
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
301
301
|
expect(rt2).to.have.members(["hoge"]);
|
|
302
302
|
});
|
|
303
|
-
it("should accept absolute src file and absolute dst file name", async ()
|
|
303
|
+
it("should accept absolute src file and absolute dst file name", async ()=>{
|
|
304
304
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.resolve(localEmptyDir, "hoge"), [], 0);
|
|
305
305
|
|
|
306
306
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
307
307
|
expect(rt2).to.have.members(["hoge"]);
|
|
308
308
|
});
|
|
309
|
-
it("should accept glob pattern as src", async ()
|
|
309
|
+
it("should accept glob pattern as src", async ()=>{
|
|
310
310
|
await recv(hostInfo, [path.posix.join(remoteRoot, "b*")], path.resolve(localEmptyDir), [], 0);
|
|
311
311
|
|
|
312
312
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
313
313
|
expect(rt2).to.have.members(["bar", "baz"]);
|
|
314
314
|
});
|
|
315
|
-
it("should accept glob pattern as src", async ()
|
|
315
|
+
it("should accept glob pattern as src", async ()=>{
|
|
316
316
|
await recv(hostInfo, [path.posix.join(remoteRoot, "*/p[iu]yo")], path.resolve(localEmptyDir), [], 0);
|
|
317
317
|
|
|
318
318
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
319
319
|
expect(rt2).to.have.members(["piyo", "puyo"]);
|
|
320
320
|
});
|
|
321
|
-
it.skip("[temporarily disabled number 23 was thrown] should accept glob pattern as src", async ()
|
|
321
|
+
it.skip("[temporarily disabled number 23 was thrown] should accept glob pattern as src", async ()=>{
|
|
322
322
|
await recv(hostInfo, [path.posix.join(remoteRoot, "hoge/p[iu]yo"), path.posix.join(remoteRoot, "foo")], path.resolve(localEmptyDir), [], 0);
|
|
323
323
|
|
|
324
324
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
325
325
|
expect(rt2).to.have.members(["piyo", "puyo", "foo"]);
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
|
-
describe("recieve directory tree", ()
|
|
329
|
-
it("should get directory tree which match specified glob", async ()
|
|
328
|
+
describe("recieve directory tree", ()=>{
|
|
329
|
+
it("should get directory tree which match specified glob", async ()=>{
|
|
330
330
|
await recv(hostInfo, [path.posix.join(remoteRoot, "?o*")], localEmptyDir, [], 0);
|
|
331
331
|
|
|
332
332
|
let rt2 = await fs.readdir(localEmptyDir);
|
|
@@ -334,7 +334,7 @@ describe("test rsync exec", function () {
|
|
|
334
334
|
rt2 = await fs.readdir(path.join(localEmptyDir, "hoge"));
|
|
335
335
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
336
336
|
});
|
|
337
|
-
it("should accept relative src dirname and relative dst dirname", async ()
|
|
337
|
+
it("should accept relative src dirname and relative dst dirname", async ()=>{
|
|
338
338
|
await recv(hostInfo, [remoteRoot], localEmptyDir, [], 0);
|
|
339
339
|
|
|
340
340
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -342,7 +342,7 @@ describe("test rsync exec", function () {
|
|
|
342
342
|
rt2 = await fs.readdir(path.join(localEmptyDir, remoteRoot, "hoge"));
|
|
343
343
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
344
344
|
});
|
|
345
|
-
it("should accept absolute src dirname and relative dst dirname", async ()
|
|
345
|
+
it("should accept absolute src dirname and relative dst dirname", async ()=>{
|
|
346
346
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], localEmptyDir, [], 0);
|
|
347
347
|
|
|
348
348
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -350,7 +350,7 @@ describe("test rsync exec", function () {
|
|
|
350
350
|
rt2 = await fs.readdir(path.join(localEmptyDir, remoteRoot, "hoge"));
|
|
351
351
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
352
352
|
});
|
|
353
|
-
it("should accept relative src dirname and absolute dst dirname", async ()
|
|
353
|
+
it("should accept relative src dirname and absolute dst dirname", async ()=>{
|
|
354
354
|
await recv(hostInfo, [remoteRoot], path.resolve(localEmptyDir), [], 0);
|
|
355
355
|
|
|
356
356
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -358,7 +358,7 @@ describe("test rsync exec", function () {
|
|
|
358
358
|
rt2 = await fs.readdir(path.join(localEmptyDir, remoteRoot, "hoge"));
|
|
359
359
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
360
360
|
});
|
|
361
|
-
it("should accept absolute src dirname and absolute dst dirname", async ()
|
|
361
|
+
it("should accept absolute src dirname and absolute dst dirname", async ()=>{
|
|
362
362
|
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], path.resolve(localEmptyDir), [], 0);
|
|
363
363
|
|
|
364
364
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -366,7 +366,7 @@ describe("test rsync exec", function () {
|
|
|
366
366
|
rt2 = await fs.readdir(path.join(localEmptyDir, remoteRoot, "hoge"));
|
|
367
367
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
368
368
|
});
|
|
369
|
-
it.skip("[not implemented] should recv files which matches only filter", async ()
|
|
369
|
+
it.skip("[not implemented] should recv files which matches only filter", async ()=>{
|
|
370
370
|
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}", [], 0);
|
|
371
371
|
|
|
372
372
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -374,13 +374,13 @@ describe("test rsync exec", function () {
|
|
|
374
374
|
rt2 = await fs.readdir(path.join(localEmptyDir, remoteRoot, "hoge"));
|
|
375
375
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
376
376
|
});
|
|
377
|
-
it("should not recv files which matches exclude filter", async ()
|
|
377
|
+
it("should not recv files which matches exclude filter", async ()=>{
|
|
378
378
|
await recv(hostInfo, [remoteRoot], localEmptyDir, ["--exclude=*/ba*", "--exclude=hoge"], [], 0);
|
|
379
379
|
|
|
380
380
|
const rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
381
381
|
expect(rt2).to.have.members(["foo", "huga"]);
|
|
382
382
|
});
|
|
383
|
-
it.skip("[not implemented] should recv files which matches only filter but should not recv which matches exclude filter", async ()
|
|
383
|
+
it.skip("[not implemented] should recv files which matches only filter but should not recv which matches exclude filter", async ()=>{
|
|
384
384
|
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}", "**/piyo", [], 0);
|
|
385
385
|
|
|
386
386
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
@@ -389,16 +389,16 @@ describe("test rsync exec", function () {
|
|
|
389
389
|
expect(rt2).to.have.members(["puyo", "poyo"]);
|
|
390
390
|
});
|
|
391
391
|
});
|
|
392
|
-
describe("degradation check", ()
|
|
393
|
-
it("should recieve multiple files from remote machine", async ()
|
|
392
|
+
describe("degradation check", ()=>{
|
|
393
|
+
it("should recieve multiple files from remote machine", async ()=>{
|
|
394
394
|
await recv(hostInfo, [path.posix.join(remoteRoot, "foo"),
|
|
395
395
|
path.posix.join(remoteRoot, "bar"), path.posix.join(remoteRoot, "baz")], localEmptyDir, [], 0);
|
|
396
396
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
397
397
|
expect(rt2).to.have.members(["foo", "bar", "baz"]);
|
|
398
398
|
});
|
|
399
399
|
});
|
|
400
|
-
describe("error case", ()
|
|
401
|
-
it("should not send directory to existing file path", ()
|
|
400
|
+
describe("error case", ()=>{
|
|
401
|
+
it("should not send directory to existing file path", ()=>{
|
|
402
402
|
return expect(recv(hostInfo, [remoteRoot], localFiles[0], [], 0)).to.be.rejected;
|
|
403
403
|
});
|
|
404
404
|
});
|
package/test/sanityCheck.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
process.on("unhandledRejection", console.dir); //
|
|
2
|
+
process.on("unhandledRejection", console.dir); //eslint-disable-line no-console
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
//setup test framework
|
|
5
5
|
const chai = require("chai");
|
|
6
6
|
const { expect } = require("chai");
|
|
7
7
|
chai.use(require("chai-as-promised"));
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
//testee
|
|
10
10
|
const { sanityCheck } = require("../lib/util.js");
|
|
11
11
|
|
|
12
|
-
describe("test for sanityCheck", ()
|
|
12
|
+
describe("test for sanityCheck", ()=>{
|
|
13
13
|
const host = "testHostName";
|
|
14
14
|
const defaultValues = {
|
|
15
15
|
ControlPersist: 180,
|
|
16
16
|
maxRetry: 3,
|
|
17
17
|
retryDuration: 1000
|
|
18
18
|
};
|
|
19
|
-
it("should throw error for empty host", ()
|
|
19
|
+
it("should throw error for empty host", ()=>{
|
|
20
20
|
expect(sanityCheck.bind(null, { host: " ", user: " ", port: 22 })).to.throw(/empty host is not allowed/);
|
|
21
21
|
});
|
|
22
|
-
it("should throw error if host is not in argument object", ()
|
|
22
|
+
it("should throw error if host is not in argument object", ()=>{
|
|
23
23
|
expect(sanityCheck.bind(null, { user: " ", port: 22 })).to.throw(/host is required/);
|
|
24
24
|
});
|
|
25
|
-
it("should just remove empty string props", ()
|
|
25
|
+
it("should just remove empty string props", ()=>{
|
|
26
26
|
expect(sanityCheck({
|
|
27
27
|
host,
|
|
28
28
|
user: " ",
|
|
@@ -33,7 +33,7 @@ describe("test for sanityCheck", () => {
|
|
|
33
33
|
port: 22
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
it("should remove empty string member in sshOpt", ()
|
|
36
|
+
it("should remove empty string member in sshOpt", ()=>{
|
|
37
37
|
expect(sanityCheck({
|
|
38
38
|
host,
|
|
39
39
|
sshOpt: ["foo", " ", "bar"],
|
|
@@ -47,7 +47,7 @@ describe("test for sanityCheck", () => {
|
|
|
47
47
|
port: 33
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
-
it("should just change type if string value specified for number", ()
|
|
50
|
+
it("should just change type if string value specified for number", ()=>{
|
|
51
51
|
expect(sanityCheck({
|
|
52
52
|
host,
|
|
53
53
|
port: "11",
|
|
@@ -64,7 +64,7 @@ describe("test for sanityCheck", () => {
|
|
|
64
64
|
retryDuration: 55
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
-
it("should remove out of range members", ()
|
|
67
|
+
it("should remove out of range members", ()=>{
|
|
68
68
|
expect(sanityCheck({
|
|
69
69
|
host,
|
|
70
70
|
ControlPersist: "-1",
|
|
@@ -75,7 +75,7 @@ describe("test for sanityCheck", () => {
|
|
|
75
75
|
host
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
it("should just change type if string value specified for boolean member", ()
|
|
78
|
+
it("should just change type if string value specified for boolean member", ()=>{
|
|
79
79
|
expect(sanityCheck({
|
|
80
80
|
host,
|
|
81
81
|
noStrictHostKeyChecking: "true"
|
|
@@ -85,7 +85,7 @@ describe("test for sanityCheck", () => {
|
|
|
85
85
|
noStrictHostKeyChecking: true
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
it("should just change type if number value specified for boolean member", ()
|
|
88
|
+
it("should just change type if number value specified for boolean member", ()=>{
|
|
89
89
|
expect(sanityCheck({
|
|
90
90
|
host,
|
|
91
91
|
noStrictHostKeyChecking: 0
|
|
@@ -95,11 +95,11 @@ describe("test for sanityCheck", () => {
|
|
|
95
95
|
noStrictHostKeyChecking: false
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
|
-
it("shold keep addtional properties", ()
|
|
98
|
+
it("shold keep addtional properties", ()=>{
|
|
99
99
|
const testData = {
|
|
100
100
|
host,
|
|
101
101
|
hoge: 3,
|
|
102
|
-
foo: ()
|
|
102
|
+
foo: ()=>{}
|
|
103
103
|
};
|
|
104
104
|
expect(sanityCheck(testData)).to.deep.equal(testData);
|
|
105
105
|
});
|