1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | Object.defineProperty(exports, "__esModule", { value: true });
|
24 | exports.ResultStorage = exports.ClientInfo = exports.TestMatrix = exports.TestMatrixBuilder = exports._testMatrixWithOpts = exports.testMatrix = exports.TEST_MATRIX_COMPLETE_EVENT_TYPE = exports.SERVICE = exports.PROVIDER = void 0;
|
25 | const cloud_functions_1 = require("../cloud-functions");
|
26 |
|
27 | exports.PROVIDER = "google.testing";
|
28 |
|
29 | exports.SERVICE = "testing.googleapis.com";
|
30 |
|
31 | exports.TEST_MATRIX_COMPLETE_EVENT_TYPE = "testMatrix.complete";
|
32 |
|
33 | function testMatrix() {
|
34 | return _testMatrixWithOpts({});
|
35 | }
|
36 | exports.testMatrix = testMatrix;
|
37 |
|
38 | function _testMatrixWithOpts(opts) {
|
39 | return new TestMatrixBuilder(() => {
|
40 | if (!process.env.GCLOUD_PROJECT) {
|
41 | throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
42 | }
|
43 | return "projects/" + process.env.GCLOUD_PROJECT + "/testMatrices/{matrix}";
|
44 | }, opts);
|
45 | }
|
46 | exports._testMatrixWithOpts = _testMatrixWithOpts;
|
47 |
|
48 | class TestMatrixBuilder {
|
49 |
|
50 | constructor(triggerResource, options) {
|
51 | this.triggerResource = triggerResource;
|
52 | this.options = options;
|
53 | }
|
54 |
|
55 | onComplete(handler) {
|
56 | const dataConstructor = (raw) => {
|
57 | return new TestMatrix(raw.data);
|
58 | };
|
59 | return (0, cloud_functions_1.makeCloudFunction)({
|
60 | provider: exports.PROVIDER,
|
61 | eventType: exports.TEST_MATRIX_COMPLETE_EVENT_TYPE,
|
62 | triggerResource: this.triggerResource,
|
63 | service: exports.SERVICE,
|
64 | dataConstructor,
|
65 | handler,
|
66 | options: this.options,
|
67 | });
|
68 | }
|
69 | }
|
70 | exports.TestMatrixBuilder = TestMatrixBuilder;
|
71 |
|
72 | class TestMatrix {
|
73 |
|
74 | constructor(data) {
|
75 | this.testMatrixId = data.testMatrixId;
|
76 | this.createTime = data.timestamp;
|
77 | this.state = data.state;
|
78 | this.outcomeSummary = data.outcomeSummary;
|
79 | this.invalidMatrixDetails = data.invalidMatrixDetails;
|
80 | this.resultStorage = new ResultStorage(data.resultStorage);
|
81 | this.clientInfo = new ClientInfo(data.clientInfo);
|
82 | }
|
83 | }
|
84 | exports.TestMatrix = TestMatrix;
|
85 |
|
86 | class ClientInfo {
|
87 |
|
88 | constructor(data) {
|
89 | this.name = (data === null || data === void 0 ? void 0 : data.name) || "";
|
90 | this.details = {};
|
91 | for (const detail of (data === null || data === void 0 ? void 0 : data.clientInfoDetails) || []) {
|
92 | this.details[detail.key] = detail.value || "";
|
93 | }
|
94 | }
|
95 | }
|
96 | exports.ClientInfo = ClientInfo;
|
97 |
|
98 | class ResultStorage {
|
99 |
|
100 | constructor(data) {
|
101 | var _a, _b, _c;
|
102 | this.gcsPath = (_a = data === null || data === void 0 ? void 0 : data.googleCloudStorage) === null || _a === void 0 ? void 0 : _a.gcsPath;
|
103 | this.toolResultsHistoryId = (_b = data === null || data === void 0 ? void 0 : data.toolResultsHistory) === null || _b === void 0 ? void 0 : _b.historyId;
|
104 | this.toolResultsExecutionId = (_c = data === null || data === void 0 ? void 0 : data.toolResultsExecution) === null || _c === void 0 ? void 0 : _c.executionId;
|
105 | this.resultsUrl = data === null || data === void 0 ? void 0 : data.resultsUrl;
|
106 | }
|
107 | }
|
108 | exports.ResultStorage = ResultStorage;
|