Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export NODEJS_IOT_EC_PUBLIC_KEY=${KOKORO_GFILE_DIR}/ec_public.pem
export NODEJS_IOT_RSA_PRIVATE_KEY=${KOKORO_GFILE_DIR}/rsa_private.pem
export NODEJS_IOT_RSA_PUBLIC_CERT=${KOKORO_GFILE_DIR}/rsa_cert.pem

# Configure Sendgrid variables
export SENDGRID_SENDER="test@google.com"
export SENDGRID_API_KEY=$(cat $KOKORO_GFILE_DIR/secrets-sendgrid-api-key.txt)

npm test

exit $?
13 changes: 13 additions & 0 deletions appengine/sendgrid/.cloud-repo-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"test": {
"app": {
"msg": "Hello World!"
}
},
"requiresKeyFile": true,
"requiresProjectId": true,
"requiredEnvVars": [
"SENDGRID_SENDER",
"SENDGRID_API_KEY"
]
}
16 changes: 2 additions & 14 deletions appengine/sendgrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@
},
"scripts": {
"start": "node app.js",
"test": "mocha test/app.test.js"
},
"cloud-repo-tools": {
"test": {
"app": {
"msg": "Value:"
}
},
"requiresKeyFile": true,
"requiresProjectId": true,
"requiredEnvVars": [
"SENDGRID_SENDER",
"SENDGRID_API_KEY"
]
"test": "repo-tools test app && mocha test/*.test.js"
},
"dependencies": {
"body-parser": "^1.19.0",
Expand All @@ -32,6 +19,7 @@
"@sendgrid/client": "^6.3.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"assert": "^1.4.1",
"mocha": "^6.1.4",
"supertest": "^4.0.2"
Expand Down
11 changes: 7 additions & 4 deletions appengine/sendgrid/test/app.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const assert = require('assert');
const Supertest = require('supertest');
const supertest = Supertest('http://localhost:8080');
const path = require('path');
const utils = require('@google-cloud/nodejs-repo-tools');

const cwd = path.join(__dirname, '../');
const request = utils.getRequest({cwd: cwd});

it('GET /: should show homepage template', async () => {
await supertest
await request
.get('/')
.expect(200)
.expect(response => {
Expand All @@ -12,7 +15,7 @@ it('GET /: should show homepage template', async () => {
});

it('POST /hello: should send an email', async () => {
await supertest
await request
.post('/hello?test=true')
.type('form')
.send({email: 'testuser@google.com'})
Expand Down