|
| 1 | +// Copyright 2019 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +'use strict'; |
| 16 | + |
| 17 | +const path = require('path'); |
| 18 | +const {assert} = require('chai'); |
| 19 | +const {describe, it} = require('mocha'); |
| 20 | +const cp = require('child_process'); |
| 21 | + |
| 22 | +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); |
| 23 | + |
| 24 | +const cwd = path.join(__dirname, '..'); |
| 25 | + |
| 26 | +const PROJECT_ID = process.env.GCLOUD_PROJECT; |
| 27 | +// Use list-build-triggers.js to figure out the ID of the trigger |
| 28 | +// you would like to execute. |
| 29 | +const TRIGGER_ID = |
| 30 | + process.env.TRIGGER || 'c9033094-51a9-44c5-b3a0-1d882deb4464'; |
| 31 | + |
| 32 | +describe('Sample Integration Tests', () => { |
| 33 | + it('should run quickstart.js', async () => { |
| 34 | + const stdout = execSync( |
| 35 | + `node ./quickstart.js ${PROJECT_ID} ${TRIGGER_ID} cloud-build-mvp`, |
| 36 | + {cwd} |
| 37 | + ); |
| 38 | + // build should have exited with success status. |
| 39 | + assert.include(stdout, 'status: Success'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should run list-build-triggers.js', async () => { |
| 43 | + const stdout = execSync( |
| 44 | + `node ./listBuildTriggers.js ${PROJECT_ID} ${TRIGGER_ID} cloud-build-mvp`, |
| 45 | + {cwd} |
| 46 | + ); |
| 47 | + assert.include(stdout, 'Push-to-any-branch'); |
| 48 | + }); |
| 49 | +}); |
0 commit comments