|
18 | 18 |
|
19 | 19 | 'use strict'; |
20 | 20 |
|
21 | | -const test = require(`ava`); |
22 | | -const path = require(`path`); |
23 | | -const utils = require(`@google-cloud/nodejs-repo-tools`); |
| 21 | +const assert = require('assert'); |
| 22 | +const path = require('path'); |
| 23 | +const utils = require('@google-cloud/nodejs-repo-tools'); |
24 | 24 |
|
25 | | -const message = `This is a test message sent at: `; |
| 25 | +const message = 'This is a test message sent at: '; |
26 | 26 | const payload = message + Date.now(); |
27 | 27 |
|
28 | | -const cwd = path.join(__dirname, `../`); |
| 28 | +const cwd = path.join(__dirname, '../'); |
29 | 29 | const requestObj = utils.getRequest({cwd: cwd}); |
30 | 30 |
|
31 | | -test.serial.cb(`should send a message to Pub/Sub`, t => { |
32 | | - requestObj |
33 | | - .post(`/`) |
| 31 | +it('should send a message to Pub/Sub', async () => { |
| 32 | + await requestObj |
| 33 | + .post('/') |
34 | 34 | .type('form') |
35 | 35 | .send({payload: payload}) |
36 | 36 | .expect(200) |
37 | 37 | .expect(response => { |
38 | | - t.regex(response.text, /Message \d* sent/); |
39 | | - }) |
40 | | - .end(t.end); |
| 38 | + assert(new RegExp(/Message \d* sent/).test(response.text)); |
| 39 | + }); |
41 | 40 | }); |
42 | 41 |
|
43 | | -test.serial.cb(`should receive incoming Pub/Sub messages`, t => { |
44 | | - requestObj |
45 | | - .post(`/pubsub/push`) |
| 42 | +it('should receive incoming Pub/Sub messages', async () => { |
| 43 | + await requestObj |
| 44 | + .post('/pubsub/push') |
46 | 45 | .query({token: process.env.PUBSUB_VERIFICATION_TOKEN}) |
47 | 46 | .send({ |
48 | 47 | message: { |
49 | 48 | data: payload, |
50 | 49 | }, |
51 | 50 | }) |
52 | | - .expect(200) |
53 | | - .end(t.end); |
| 51 | + .expect(200); |
54 | 52 | }); |
55 | 53 |
|
56 | | -test.serial.cb( |
57 | | - `should check for verification token on incoming Pub/Sub messages`, |
58 | | - t => { |
59 | | - requestObj |
60 | | - .post(`/pubsub/push`) |
61 | | - .field(`payload`, payload) |
62 | | - .expect(400) |
63 | | - .end(t.end); |
64 | | - } |
65 | | -); |
| 54 | +it('should check for verification token on incoming Pub/Sub messages', async () => { |
| 55 | + await requestObj |
| 56 | + .post('/pubsub/push') |
| 57 | + .field('payload', payload) |
| 58 | + .expect(400); |
| 59 | +}); |
66 | 60 |
|
67 | | -test.serial.cb(`should list sent Pub/Sub messages`, t => { |
68 | | - requestObj |
69 | | - .get(`/`) |
| 61 | +it('should list sent Pub/Sub messages', async () => { |
| 62 | + await requestObj |
| 63 | + .get('/') |
70 | 64 | .expect(200) |
71 | 65 | .expect(response => { |
72 | | - t.regex(response.text, /Messages received by this instance/); |
73 | | - }) |
74 | | - .end(t.end); |
| 66 | + assert( |
| 67 | + new RegExp(/Messages received by this instance/).test(response.text) |
| 68 | + ); |
| 69 | + }); |
75 | 70 | }); |
0 commit comments