-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.js
150 lines (132 loc) · 4.65 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
'use strict'
const test = require('tape')
const after = require('after')
const latestCommit = require('./latest-commit')
const listBuilds = require('./list-builds')
const ghauth = require('ghauth')
const AppCfg = require('application-config')
const authOptions = {
configName: 'nodejs-nightly-builder',
scope: [],
note: 'nodejs-nightly-builder tests'
}
if (process.argv[2] === 'auth') {
ghauth(authOptions, (err, authData) => {
if (err) {
throw err
}
console.log('Saved authentication credentials, go forth and test')
})
} else {
test('list-builds', (t) => {
t.plan(7)
let other = null
const verify = () => {
return (err, data) => {
t.error(err, 'no error')
t.ok(Array.isArray(data), 'is array')
t.ok(data.length > 1, 'has data')
const m = data[0].version && data[0].version.match(/v\d+\.\d+\.\d+-nightly20\d{6}\w{10,}/)
t.ok(m, `version (${data[0].version}) looks correct`)
t.ok(data[0].date < new Date(), `date (${data[0].date.toISOString()}) looks correct`)
t.ok(data[0].commit && data[0].commit.length >= 10, `commit (${data[0].commit}) looks right`)
t.notEqual(data[0].commit, other, 'commit not the same as other type of commit')
other = data[0].commit // who's gonna be first??
}
}
listBuilds('nightly', {}, verify())
})
test('list-builds chakracore-nightly', (t) => {
t.plan(6)
let data1
let data2
const verify = () => {
return (err) => {
t.error(err, 'no error')
t.ok(Array.isArray(data1), ' data1 is array')
t.ok(data1.length > 1, 'data1 has data')
t.ok(Array.isArray(data2), 'data2 is array')
t.ok(data2.length > 1, 'data2 has data')
t.notDeepEqual(data1, data2, 'different data with and without urlTypePrefix')
}
}
const done = after(2, verify())
listBuilds('nightly', {}, (err, data) => {
data1 = data
done(err)
})
listBuilds('nightly', { urlTypePrefix: 'chakracore-' }, (err, data) => {
data2 = data
done(err)
})
})
test('list-builds v8-canary', (t) => {
t.plan(7)
let other = null
const verify = () => {
return (err, data) => {
t.error(err, 'no error')
t.ok(Array.isArray(data), 'is array')
t.ok(data.length >= 1, 'has data')
const m = data[0].version && data[0].version.match(/v\d+\.\d+\.\d+-v8-canary20\d{6}\w{10,}/)
t.ok(m, `version (${data[0].version}) looks correct`)
t.ok(data[0].date < new Date(), `date (${data[0].date.toISOString()}) looks correct`)
t.ok(data[0].commit && data[0].commit.length >= 10, `commit (${data[0].commit}) looks right`)
t.notEqual(data[0].commit, other, 'commit not the same as other type of commit')
other = data[0].commit // who's gonna be first??
}
}
listBuilds('v8-canary', {}, verify())
})
test('latest-commit', (t) => {
t.plan(4)
let other = null
new AppCfg(authOptions.configName).read()
.catch(() => {
console.error('You need GitHub authentication credentials saved first, run `node test.js auth` to set this up')
return process.exit(1)
}).then((config) => {
const verify = () => {
return (err, sha) => {
t.error(err, 'no error')
t.equal(typeof sha, 'string', 'got sha')
t.equal(sha.length, 40, `sha looks good (${sha})`)
t.notEqual(sha, other, 'sha not the same as other type of sha')
other = sha // who's gonna be first??
}
}
latestCommit('nightly', 'heads/v5.x', {
githubOrg: 'nodejs',
githubRepo: 'node',
githubAuthUser: config.user,
githubAuthToken: config.token
}, verify())
})
})
test('latest-commit v8-canary', (t) => {
t.plan(4)
let other = null
new AppCfg(authOptions.configName).read()
.catch(() => {
console.error('You need GitHub authentication credentials saved first, run `node test.js auth` to set this up')
return process.exit(1)
})
.then((config) => {
const verify = () => {
return (err, sha) => {
t.error(err, 'no error')
t.equal(typeof sha, 'string', 'got sha')
t.equal(sha.length, 40, `sha looks good (${sha})`)
t.notEqual(sha, other, 'sha not the same as other type of sha')
other = sha // who's gonna be first??
}
}
latestCommit('v8-canary', 'heads/canary', {
githubOrg: 'nodejs',
githubRepo: 'node-v8',
githubAuthUser: config.user,
githubAuthToken: config.token
}, verify())
})
})
}