-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
158 lines (141 loc) · 4.29 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
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
158
var test = require('ava');
var fs = require('fs');
var desc = require('.');
test.cb('D1', function(t) {
desc(fs.createReadStream('./test/D1', { 'encoding': 'utf8' }),
function(err, d) {
t.is(err, null);
t.is(d.Package, 'parr');
t.is(d.Maintainer, 'Gabor Csardi <[email protected]>');
t.is(d.RoxygenNote, '5.0.1');
t.end();
});
});
test.cb('D2', function(t) {
desc(fs.createReadStream('./test/D2', { 'encoding': 'utf8' }),
function(err, d) {
t.is(err, null);
t.is(d.Package, 'roxygen2');
t.is(d.Depends.length, 1);
t.is(d.Imports.length, 8);
t.deepEqual(d.Depends[0], {package: 'R', version: '>= 3.0.2'});
t.deepEqual(d.Imports[0], {package: 'stringr', version: '>= 0.5'});
t.deepEqual(d.Imports[1], {package: 'stringi'});
t.deepEqual(d.Imports[5], {package: 'Rcpp', version: '>= 0.11.0'});
t.deepEqual(d.Suggests[0], {package: 'testthat', version: '>= 0.8.0'});
t.end();
});
});
test.cb('D3', function(t) {
desc(fs.createReadStream('./test/D3', { 'encoding': 'utf8' }),
function(err, d) {
t.is(err, "Invalid record: ");
t.end();
});
})
test.cb('parse_desc_file', function(t) {
desc.parse_desc_file('./test/D1', function(err, d) {
t.is(err, null);
t.is(d.Package, 'parr');
t.is(d.Maintainer, 'Gabor Csardi <[email protected]>');
t.is(d.RoxygenNote, '5.0.1');
t.end();
});
});
test.cb('parse_tar_stream', function(t) {
desc.parse_tar_stream(
fs.createReadStream('./test/foobar_1.0.0.tar'),
function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_tar_stream, gzipped', function(t) {
desc.parse_tar_stream(
fs.createReadStream('./test/foobar_1.0.0.tar.gz'),
function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_tar_file', function(t) {
desc.parse_tar_file('./test/foobar_1.0.0.tar', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_tar_file, gzipped', function(t) {
desc.parse_tar_file('./test/foobar_1.0.0.tar.gz', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_zip_stream', function(t) {
desc.parse_zip_stream(
fs.createReadStream('./test/foobar_1.0.0.zip'),
function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_zip_file', function(t) {
desc.parse_zip_file('./test/foobar_1.0.0.zip', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_file, plain file', function(t) {
desc.parse_file('./test/D1', function(err, d) {
t.is(err, null);
t.is(d.Package, 'parr');
t.is(d.Maintainer, 'Gabor Csardi <[email protected]>');
t.is(d.RoxygenNote, '5.0.1');
t.end();
});
});
test.cb('parse_file, tar file', function(t) {
desc.parse_file('./test/foobar_1.0.0.tar', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_file, tar.gz file', function(t) {
desc.parse_file('./test/foobar_1.0.0.tar.gz', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.end();
});
});
test.cb('parse_file, zip file', function(t) {
desc.parse_file('./test/foobar_1.0.0.zip', function(err, d) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.is(d.Built.R, '3.4.3');
t.is(d.Built.Platform, '');
t.is(d.Built.Date, '2017-12-25 19:19:13 UTC');
t.is(d.Built.OStype, 'unix');
t.end();
});
});
test.cb('parse dependency string', function(t){
var deps = desc.parse_dep_string("foo (>= 1.2.3), bar");
t.deepEqual(deps[0], {package:'foo', version: '>= 1.2.3'});
t.deepEqual(deps[1], {package:'bar'});
t.end();
});