-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathflowhook.js
109 lines (95 loc) · 3.32 KB
/
flowhook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// flowhook.js
// ------------------------------------------------------------------
//
// tests for Flowhooks
//
// Copyright 2017-2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// created: Sat Apr 29 09:17:48 2017
// last saved: <2021-March-22 17:24:02>
/* global describe, faker, it, path, before */
var common = require('./common');
describe('Flowhook', function() {
this.timeout(common.testTimeout) ;
this.slow(common.slowThreshold);
common.connectApigee(function(org){
describe('fails', function() {
it('should fail to list flowhooks', function(done) {
org.flowhooks.get({}, function(e, result){
assert.isNotNull(e, "expected error is missing");
assert.equal(e, "Error: missing required parameter: environment");
done();
});
});
});
describe('get/list', function() {
this.timeout(common.testTimeout);
var combinations = [];
before(function(done){
org.environments.get(function(e, result) {
assert.isNull(e, "error listing: " + JSON.stringify(e));
var envlist = result;
var numDone = 0;
result.forEach(function(env){
org.flowhooks.get({environment:env}, function(e, result) {
numDone++;
combinations.push([env, result]);
if (numDone == envlist.length) {
done();
}
});
});
});
});
it('should get the list of flowhooks for each environment', function(done) {
var numDoneEnv = 0;
combinations.forEach(function(combo) {
var env = combo[0];
assert.isNotNull(env, "error");
org.flowhooks.get({environment:env}, function(e, result) {
assert.isNull(e, "error listing: " + JSON.stringify(e));
assert.isNotNull(result, "result is empty");
assert.equal(result.length, 4, "unexpected number of hooks");
numDoneEnv++;
if (numDoneEnv == combinations.length) {
done();
}
});
});
});
it('should get individual flowhooks for each environment', function(done) {
var numDoneEnv = 0;
combinations.forEach(function(combo) {
var env = combo[0], hooks = combo[1];
assert.isNotNull(env, "error");
var numDoneHooks = 0;
hooks.forEach(function(hook) {
org.flowhooks.get({environment:env, name:hook}, function(e, result) {
assert.isNull(e, "error: " + JSON.stringify(e));
assert.isNotNull(result, "error");
numDoneHooks++;
if (numDoneHooks == hooks.length) {
numDoneEnv++;
if (numDoneEnv == combinations.length) {
done();
}
}
});
});
});
});
});
});
});