Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions integration_test/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
How to Use
---------

***ATTENTION***: Running this test will wipe the contents of the Firebase project you run it against. Make sure you use a disposable Firebase project!
***ATTENTION***: Running this test will wipe the contents of the Firebase project(s) you run it against. Make sure you use disposable Firebase project(s)!

Run the integration test as follows:

```bash
./run_tests.sh <project_id>
./run_tests.sh <project_id> [<project_id2>]
```
If just one project_id is provided, the both the node6 and node8 tests will be run on that project, in series. If two project_ids are provided, the node6 tests will be run on the first project and the node8 tests will be run on the second one, in parallel.

The tests run fully automatically, and will print the result on standard out. The integration test for HTTPS is that it properly kicks off other integration tests and returns a result. From there the other integration test suites will write their results back to the database, where you can check the detailed results if you'd like.
6 changes: 5 additions & 1 deletion integration_test/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as functions from 'firebase-functions';
import * as https from 'https';
import * as admin from 'firebase-admin';
import { Request, Response } from 'express';
import * as fs from 'fs'

import * as PubSub from '@google-cloud/pubsub';
const pubsub = PubSub();
Expand All @@ -12,6 +13,7 @@ export * from './auth-tests';
export * from './firestore-tests';
export * from './https-tests';
export * from './remoteConfig-tests';
export * from './storage-tests';
const numTests = Object.keys(exports).length; // Assumption: every exported function is its own test.

import 'firebase-functions'; // temporary shim until process.env.FIREBASE_CONFIG available natively in GCF(BUG 63586213)
Expand Down Expand Up @@ -57,7 +59,7 @@ export const integrationTests: any = functions
.ref()
.push().key;
console.log('testId is: ', testId);

fs.writeFile('/tmp/' + testId + '.txt', 'test', ()=> {});
return Promise.all([
// A database write to trigger the Firebase Realtime Database tests.
admin
Expand Down Expand Up @@ -107,6 +109,8 @@ export const integrationTests: any = functions
request.write(JSON.stringify({ version: { description: testId } }));
request.end();
}),
// A storage upload to trigger the Storage tests
admin.storage().bucket().upload('/tmp/' + testId + '.txt'),
// Invoke a callable HTTPS trigger.
callHttpsTrigger('callableTests', { foo: 'bar', testId }),
])
Expand Down
26 changes: 26 additions & 0 deletions integration_test/functions/src/storage-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as functions from 'firebase-functions';
import { TestSuite, expectEq, expectDeepEq } from './testing';
import ObjectMetadata = functions.storage.ObjectMetadata;
const testIdFieldName = 'documentId';

export const storageTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.storage.bucket().object()
.onFinalize((s, c) => {
const testId = s.name.split('.')[0];
return new TestSuite<ObjectMetadata>('storage object finalize')

.it('should not have event.app', (data, context) => !(context as any).app)

.it('should have the right eventType', (snap, context) =>
expectEq(context.eventType, 'google.storage.object.finalize')
)

.it('should have eventId', (snap, context) => context.eventId)

.it('should have timestamp', (snap, context) => context.timestamp)

.run(testId, s, c);
});
2 changes: 1 addition & 1 deletion integration_test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -e

function usage {
echo "Usage: $0 <project_id_node_6> <project_id_node_8>"
echo "Usage: $0 <project_id_node_6> [<project_id_node_8>]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks for updating the usage as well

exit 1
}

Expand Down