-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathares-pull.spec.js
157 lines (143 loc) · 4.89 KB
/
ares-pull.spec.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright (c) 2020-2024 LG Electronics Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
const path = require('path'),
exec = require('child_process').exec,
common = require('./common-spec');
const aresCmd = 'ares-pull',
dstPath = path.join(__dirname, "..", "tempFiles");
let cmd,
options;
beforeAll(function(done) {
cmd = common.makeCmd(aresCmd);
common.getOptions()
.then(function(result) {
options = result;
done();
});
});
describe(aresCmd + ' -v', function() {
it('Print help message with verbose log', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ' -v', function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
expect(stderr).toContain("verb argv");
}
expect(stdout).toContain("SYNOPSIS");
expect(error).toBeNull();
done();
});
});
});
describe(aresCmd, function() {
it("Add device with ares-setup-device", function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
common.resetDeviceList()
.then(function() {
return common.addDeviceInfo();
}).then(function(result) {
expect(result).toContain(options.device);
done();
}).catch(function(err) {
expect(err).toContain("The specified value already exist");
done();
});
});
});
describe(aresCmd + ' --device-list(-D)', function() {
it('Show available device list', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ' -D', function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
}
expect(stdout).toContain(options.device);
expect(stdout).toContain(options.profile);
done();
});
});
});
describe(aresCmd, function() {
beforeEach(function(done) {
const shellCmd = common.makeCmd('ares-shell');
exec(shellCmd + ' -r "touch /tmp/aresfile"', function() {
done();
});
});
it('Copy directory from a device to host machine', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ` /tmp/aresfile ${dstPath}`, function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
}
expect(stdout).toContain("[Info] Set target device : " + options.device);
expect(stdout).toContain("Processing");
expect(stdout).toContain(dstPath);
expect(stdout).toContain("1 file(s) pulled");
done();
});
});
});
describe(aresCmd + ' --ignore(-i)', function() {
it('Copy directory from a device to host machine', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ` -i /tmp/aresfile ${dstPath}`, function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
}
expect(stdout).not.toContain(dstPath);
expect(stdout).toContain("1 file(s) pulled");
done();
});
});
afterEach(function(done) {
common.removeOutDir(path.join(dstPath, "aresfile"));
done();
});
});
describe(aresCmd + ' negative TC', function() {
beforeEach(function(done) {
const shellCmd = common.makeCmd('ares-shell');
exec(shellCmd + ' -r "touch /tmp/aresfile"', function() {
done();
});
});
it('Copy file to not exist local directory', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ` /tmp/aresfile invalidDir`, function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
expect(stderr).toContain("ares-pull ERR! [syscall failure]: ENOENT: no such file or directory, lstat");
expect(stderr).toContain("ares-pull ERR! [Tips]: Please check if the path is valid");
}
done();
});
});
it('Copy invalid file from target', function(done) {
if (options.profile === "tv") {
pending(options.skipTxt);
}
exec(cmd + ` /tmp/invalidFile tempDir`, function(error, stdout, stderr) {
if (stderr && stderr.length > 0) {
common.detectNodeMessage(stderr);
expect(stderr).toContain("ares-pull ERR! [Tips]: The specified path does not exist <SOURCE> : /tmp/invalidFile");
}
done();
});
});
});