Skip to content

Commit 2ae01ad

Browse files
committed
Add test HEAD requests. CheckerNetwork/spark-checker#104
1 parent 0fb461e commit 2ae01ad

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

api/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const createMeasurement = async (req, res, client) => {
8585
validate(measurement, 'timeout', { type: 'boolean', required: false })
8686
validate(measurement, 'startAt', { type: 'date', required: false })
8787
validate(measurement, 'statusCode', { type: 'number', required: false })
88+
validate(measurement, 'headStatusCode', { type: 'number', required: false })
8889
validate(measurement, 'firstByteAt', { type: 'date', required: false })
8990
validate(measurement, 'endAt', { type: 'date', required: false })
9091
validate(measurement, 'byteLength', { type: 'number', required: false })
@@ -112,6 +113,7 @@ const createMeasurement = async (req, res, client) => {
112113
timeout,
113114
start_at,
114115
status_code,
116+
head_status_code,
115117
first_byte_at,
116118
end_at,
117119
byte_length,
@@ -125,7 +127,7 @@ const createMeasurement = async (req, res, client) => {
125127
completed_at_round
126128
)
127129
SELECT
128-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20,
130+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21,
129131
id as completed_at_round
130132
FROM spark_rounds
131133
ORDER BY id DESC
@@ -142,6 +144,7 @@ const createMeasurement = async (req, res, client) => {
142144
measurement.timeout || false,
143145
parseOptionalDate(measurement.startAt),
144146
measurement.statusCode,
147+
measurement.headStatusCode,
145148
parseOptionalDate(measurement.firstByteAt),
146149
parseOptionalDate(measurement.endAt),
147150
measurement.byteLength,
@@ -182,6 +185,7 @@ const getMeasurement = async (req, res, client, measurementId) => {
182185
timeout: resultRow.timeout,
183186
startAt: resultRow.start_at,
184187
statusCode: resultRow.status_code,
188+
headStatusCode: resultRow.head_status_code,
185189
firstByteAt: resultRow.first_byte_at,
186190
endAt: resultRow.end_at,
187191
byteLength: resultRow.byte_length,

api/test/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const VALID_MEASUREMENT = {
2929
participantAddress,
3030
startAt: new Date(),
3131
statusCode: 200,
32+
headStatusCode: 200,
3233
firstByteAt: new Date(),
3334
endAt: new Date(),
3435
byteLength: 100,
@@ -167,6 +168,7 @@ describe('Routes', () => {
167168
measurement.startAt.toJSON()
168169
)
169170
assert.strictEqual(measurementRow.status_code, measurement.statusCode)
171+
assert.strictEqual(measurementRow.head_status_code, measurement.headStatusCode)
170172
assert.strictEqual(
171173
measurementRow.first_byte_at.toJSON(),
172174
measurement.firstByteAt.toJSON()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE measurements ADD COLUMN head_status_code INTEGER;

publish/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const publish = async ({
2424
timeout,
2525
start_at,
2626
status_code,
27+
head_status_code,
2728
first_byte_at,
2829
end_at,
2930
byte_length,

publish/test/test-helpers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const insertMeasurement = async (client, measurement) => {
1717
timeout,
1818
start_at,
1919
status_code,
20+
head_status_code,
2021
first_byte_at,
2122
end_at,
2223
byte_length,
@@ -30,7 +31,7 @@ export const insertMeasurement = async (client, measurement) => {
3031
completed_at_round
3132
)
3233
VALUES (
33-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20
34+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21
3435
)
3536
`, [
3637
measurement.sparkVersion,
@@ -42,6 +43,7 @@ export const insertMeasurement = async (client, measurement) => {
4243
measurement.timeout,
4344
measurement.startAt,
4445
measurement.statusCode,
46+
measurement.headStatusCode,
4547
measurement.firstByteAt,
4648
measurement.endAt,
4749
measurement.byteLength,

0 commit comments

Comments
 (0)