Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c1bd04
commit 8ebc4a3
Showing
5 changed files
with
171 additions
and
2 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
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,18 @@ | ||
import * as backend from "../backend"; | ||
import { FirebaseError } from "../../../error"; | ||
|
||
/** | ||
* Sets a Test Lab event trigger's region to 'global' since the service is global | ||
* @param endpoint the test lab endpoint | ||
*/ | ||
export function ensureTestLabTriggerRegion( | ||
endpoint: backend.Endpoint & backend.EventTriggered | ||
): Promise<void> { | ||
if (!endpoint.eventTrigger.region) { | ||
endpoint.eventTrigger.region = "global"; | ||
} | ||
if (endpoint.eventTrigger.region !== "global") { | ||
throw new FirebaseError("A test lab trigger must specify 'global' trigger location"); | ||
} | ||
return Promise.resolve(); | ||
} |
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
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,47 @@ | ||
import { expect } from "chai"; | ||
import { Endpoint } from "../../../../deploy/functions/backend"; | ||
import * as testLab from "../../../../deploy/functions/services/testLab"; | ||
|
||
const projectNumber = "123456789"; | ||
|
||
const endpoint: Endpoint = { | ||
id: "endpoint", | ||
region: "us-central1", | ||
project: projectNumber, | ||
eventTrigger: { | ||
retry: false, | ||
eventType: "google.firebase.testlab.testMatrix.v1.completed", | ||
eventFilters: {}, | ||
}, | ||
entryPoint: "endpoint", | ||
platform: "gcfv2", | ||
runtime: "nodejs16", | ||
}; | ||
|
||
describe("ensureTestLabTriggerRegion", () => { | ||
it("should set the trigger location to global", async () => { | ||
const ep = { ...endpoint }; | ||
|
||
await testLab.ensureTestLabTriggerRegion(ep); | ||
|
||
expect(ep.eventTrigger.region).to.eq("global"); | ||
}); | ||
|
||
it("should not error if the trigger location is global", async () => { | ||
const ep = { ...endpoint }; | ||
ep.eventTrigger.region = "global"; | ||
|
||
await testLab.ensureTestLabTriggerRegion(ep); | ||
|
||
expect(ep.eventTrigger.region).to.eq("global"); | ||
}); | ||
|
||
it("should error if the trigger location is not global", () => { | ||
const ep = { ...endpoint }; | ||
ep.eventTrigger.region = "us-west1"; | ||
|
||
expect(() => testLab.ensureTestLabTriggerRegion(ep)).to.throw( | ||
"A test lab trigger must specify 'global' trigger location" | ||
); | ||
}); | ||
}); |