-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GCF: Add Stackdriver trigger sample (#740)
* Add stackdriver BigQuery trigger sample * Make sample product-agnostic
- Loading branch information
Ace Nassri
authored
Sep 25, 2018
1 parent
6189438
commit 292308b
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,3 +85,31 @@ test.serial(`getMetrics: should retrieve metrics`, (t) => { | |
|
||
t.is(callback.callCount, 1); | ||
}); | ||
|
||
test(`processLogEntry: should process log entry`, (t) => { | ||
const sample = getSample(); | ||
const callback = sinon.stub(); | ||
|
||
const json = JSON.stringify({ | ||
protoPayload: { | ||
methodName: 'method', | ||
resourceName: 'resource', | ||
authenticationInfo: { | ||
principalEmail: '[email protected]' | ||
} | ||
} | ||
}); | ||
|
||
const data = { | ||
data: { | ||
data: Buffer.from(json, 'ascii') | ||
} | ||
}; | ||
|
||
sample.program.processLogEntry(data, callback); | ||
|
||
t.true(console.log.calledWith(`Method: method`)); | ||
t.true(console.log.calledWith(`Resource: resource`)); | ||
t.true(console.log.calledWith(`Initiator: [email protected]`)); | ||
t.is(callback.callCount, 1); | ||
}); |