-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
41 lines (31 loc) · 1015 Bytes
/
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
'use strict'
const t = require('tap')
const Fastify = require('fastify')
const fastifyGoogleCloudStorage = require('./index')
t.test('should register', t => {
t.plan(2)
const realProjectId = require('./testData/realConfiguration.json').projectId
const realKeyFilename = './testData/sa.json'
const fastify = Fastify()
fastify.register(fastifyGoogleCloudStorage, {
projectId: realProjectId,
keyFilename: realKeyFilename
})
fastify.ready(err => {
t.error(err)
if (err) console.log(`Could not register GCS plugin. Reason is: ${err.message}\n`)
t.ok(fastify.googleCloudStorage)
})
})
t.test('should not register on invalid credentials', t => {
t.plan(2)
const fastify = Fastify()
fastify.register(fastifyGoogleCloudStorage, {
projectId: 'FAKE-IT'
})
fastify.ready(err => {
t.ok(err)
t.equal(err.message.includes('Invalid project number'), true)
if (err) console.log(`Tried to register on not existing project. Result is: ${err.message}\n`)
})
})