|
| 1 | +// Copyright 2021 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 | +// https://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 | + |
| 16 | +'use strict'; |
| 17 | + |
| 18 | +const {assert} = require('chai'); |
| 19 | +const {before, describe, it} = require('mocha'); |
| 20 | +const cp = require('child_process'); |
| 21 | +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); |
| 22 | + |
| 23 | +const { |
| 24 | + ContactCenterInsightsClient, |
| 25 | +} = require('@google-cloud/contact-center-insights'); |
| 26 | +const client = new ContactCenterInsightsClient(); |
| 27 | + |
| 28 | +describe('GetOperation', () => { |
| 29 | + let projectId; |
| 30 | + |
| 31 | + before(async () => { |
| 32 | + projectId = await client.getProjectId(); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should get an operation', async () => { |
| 36 | + /** |
| 37 | + * TODO(developer): Replace this variable with your operation name. |
| 38 | + */ |
| 39 | + const operationName = `projects/${projectId}/locations/us-central1/operations/12345`; |
| 40 | + |
| 41 | + try { |
| 42 | + const stdout = execSync(`node ./getOperation.js ${operationName}`); |
| 43 | + assert.match(stdout, new RegExp(`Got operation ${operationName}`)); |
| 44 | + } catch (e) { |
| 45 | + if (!e.message.includes('not found')) { |
| 46 | + throw e; |
| 47 | + } |
| 48 | + } |
| 49 | + }); |
| 50 | +}); |
0 commit comments