@itentialopensource/adapter-git 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +640 -0
- package/SUMMARY.md +9 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +112 -1
- package/error.json +12 -0
- package/metadata.json +47 -0
- package/package.json +14 -16
- package/pronghorn.json +78 -2
- package/propertiesDecorators.json +14 -0
- package/refs?service=git-upload-pack +0 -0
- package/test/integration/adapterTestIntegration.js +52 -0
- package/test/unit/adapterTestUnit.js +84 -23
- package/utils/adapterInfo.js +206 -0
- package/utils/artifactize.js +1 -1
- package/utils/packModificationScript.js +1 -1
- package/utils/removeHooks.js +20 -0
- package/utils/testRunner.js +17 -17
package/TROUBLESHOOT.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Troubleshoot
|
|
2
|
+
|
|
3
|
+
Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows you to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
|
|
4
|
+
|
|
5
|
+
You also have the option to run individual commands to perform specific test:
|
|
6
|
+
|
|
7
|
+
- `npm run healthcheck` will perform a healthcheck request of with current setting.
|
|
8
|
+
- `npm run basicget` will perform some non-parameter GET request with current setting.
|
|
9
|
+
- `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
|
|
10
|
+
|
|
11
|
+
### Connectivity Issues
|
|
12
|
+
|
|
13
|
+
1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run troubleshoot
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Verify the adapter properties are set up correctly.
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Verify there is connectivity between the Itential Platform Server and Git Server.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
ping the ip address of Git server
|
|
29
|
+
try telnet to the ip address port of Git
|
|
30
|
+
execute a curl command to the other system
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Verify the credentials provided for Git.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
login to Git using the provided credentials
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Verify the API of the call utilized for Git Healthcheck.
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Functional Issues
|
|
46
|
+
|
|
47
|
+
Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters can be configured to log into their own files.
|
package/adapter.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
/* eslint import/no-dynamic-require: warn */
|
|
11
11
|
/* eslint global-require: warn */
|
|
12
12
|
/* eslint no-await-in-loop: warn */
|
|
13
|
+
/* eslint default-param-last: warn */
|
|
13
14
|
|
|
14
15
|
/* Required libraries. */
|
|
15
16
|
const fs = require('fs-extra');
|
|
@@ -252,6 +253,72 @@ class Git extends EventEmitterCl {
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
|
|
256
|
+
createBranch(options, callback) {
|
|
257
|
+
const meth = 'adapter-createBranch';
|
|
258
|
+
const origin = `${this.id}-${meth}`;
|
|
259
|
+
log.trace(origin);
|
|
260
|
+
try {
|
|
261
|
+
// verify the required data has been provided
|
|
262
|
+
if (options === undefined || options === null || options === '') {
|
|
263
|
+
const errorObj = formatErrorObject(origin, 'Missing Data', ['options'], null, null, null);
|
|
264
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
265
|
+
return callback(null, errorObj);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const copiedOptions = { ...options };
|
|
269
|
+
copiedOptions.fs = fs;
|
|
270
|
+
git.branch(copiedOptions)
|
|
271
|
+
.then(() => callback({
|
|
272
|
+
status: 'success',
|
|
273
|
+
code: 200
|
|
274
|
+
}))
|
|
275
|
+
.catch((err) => {
|
|
276
|
+
const errorObj = formatErrorObject(origin, 'Creating new branch failed', null, null, null, err);
|
|
277
|
+
log.error('error:', err);
|
|
278
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
279
|
+
return callback(null, errorObj);
|
|
280
|
+
});
|
|
281
|
+
} catch (ex) {
|
|
282
|
+
const errorObj = formatErrorObject(origin, 'Caught Exception', null, null, null, ex);
|
|
283
|
+
log.error(ex);
|
|
284
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
285
|
+
return callback(null, errorObj);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
checkoutBranch(options, callback) {
|
|
290
|
+
const meth = 'adapter-checkoutBranch';
|
|
291
|
+
const origin = `${this.id}-${meth}`;
|
|
292
|
+
log.trace(origin);
|
|
293
|
+
try {
|
|
294
|
+
// verify the required data has been provided
|
|
295
|
+
if (options === undefined || options === null || options === '') {
|
|
296
|
+
const errorObj = formatErrorObject(origin, 'Missing Data', ['options'], null, null, null);
|
|
297
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
298
|
+
return callback(null, errorObj);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const copiedOptions = { ...options };
|
|
302
|
+
copiedOptions.fs = fs;
|
|
303
|
+
git.checkout(copiedOptions)
|
|
304
|
+
.then(() => callback({
|
|
305
|
+
status: 'success',
|
|
306
|
+
code: 200
|
|
307
|
+
}))
|
|
308
|
+
.catch((err) => {
|
|
309
|
+
const errorObj = formatErrorObject(origin, 'Checking out failed', null, null, null, err);
|
|
310
|
+
log.error('error:', err);
|
|
311
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
312
|
+
return callback(null, errorObj);
|
|
313
|
+
});
|
|
314
|
+
} catch (ex) {
|
|
315
|
+
const errorObj = formatErrorObject(origin, 'Caught Exception', null, null, null, ex);
|
|
316
|
+
log.error(ex);
|
|
317
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
318
|
+
return callback(null, errorObj);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
255
322
|
removeFile(options, callback) {
|
|
256
323
|
const meth = 'adapter-removeFile';
|
|
257
324
|
const origin = `${this.id}-${meth}`;
|
|
@@ -456,7 +523,7 @@ class Git extends EventEmitterCl {
|
|
|
456
523
|
}
|
|
457
524
|
}
|
|
458
525
|
|
|
459
|
-
removeAndPushFile(cloneOptions, removeFileOptions, commitOptions, pushOptions, callback) {
|
|
526
|
+
removeAndPushFile(cloneOptions, createAndCheckoutNewBranch = false, checkoutExistingBranch = false, branchOptions, checkoutOptions, removeFileOptions, commitOptions, pushOptions, callback) {
|
|
460
527
|
const meth = 'adapter-removeAndPushFile';
|
|
461
528
|
const origin = `${this.id}-${meth}`;
|
|
462
529
|
log.trace(origin);
|
|
@@ -483,6 +550,24 @@ class Git extends EventEmitterCl {
|
|
|
483
550
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
484
551
|
return callback(null, errorObj);
|
|
485
552
|
}
|
|
553
|
+
if (createAndCheckoutNewBranch) {
|
|
554
|
+
if (branchOptions === undefined || branchOptions === null || branchOptions === '') {
|
|
555
|
+
const errorObj = formatErrorObject(origin, 'Missing Data', ['branch options'], null, null, null);
|
|
556
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
557
|
+
return callback(null, errorObj);
|
|
558
|
+
}
|
|
559
|
+
if (checkoutOptions === undefined || checkoutOptions === null || checkoutOptions === '') {
|
|
560
|
+
const errorObj = formatErrorObject(origin, 'Missing Data', ['checkout options'], null, null, null);
|
|
561
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
562
|
+
return callback(null, errorObj);
|
|
563
|
+
}
|
|
564
|
+
} else if (!createAndCheckoutNewBranch && checkoutExistingBranch) {
|
|
565
|
+
if (checkoutOptions === undefined || checkoutOptions === null || checkoutOptions === '') {
|
|
566
|
+
const errorObj = formatErrorObject(origin, 'Missing Data', ['checkout options'], null, null, null);
|
|
567
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
568
|
+
return callback(null, errorObj);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
486
571
|
|
|
487
572
|
const copiedCloneOptions = { ...cloneOptions };
|
|
488
573
|
copiedCloneOptions.fs = fs;
|
|
@@ -512,6 +597,32 @@ class Git extends EventEmitterCl {
|
|
|
512
597
|
task: 'clone',
|
|
513
598
|
result: 'success'
|
|
514
599
|
});
|
|
600
|
+
if (createAndCheckoutNewBranch) {
|
|
601
|
+
const copiedBranchOptions = { ...branchOptions };
|
|
602
|
+
const copiedCheckoutOptions = { ...checkoutOptions };
|
|
603
|
+
copiedBranchOptions.fs = fs;
|
|
604
|
+
copiedCheckoutOptions.fs = fs;
|
|
605
|
+
return git.branch(copiedBranchOptions)
|
|
606
|
+
.then(() => git.checkout(copiedCheckoutOptions));
|
|
607
|
+
}
|
|
608
|
+
if (checkoutExistingBranch) {
|
|
609
|
+
const copiedCheckoutOptions = { ...checkoutOptions };
|
|
610
|
+
copiedCheckoutOptions.fs = fs;
|
|
611
|
+
return git.checkout(copiedCheckoutOptions);
|
|
612
|
+
}
|
|
613
|
+
})
|
|
614
|
+
.then(() => {
|
|
615
|
+
if (createAndCheckoutNewBranch) {
|
|
616
|
+
successfulResult.results.push({
|
|
617
|
+
task: 'create and checkout new branch',
|
|
618
|
+
result: 'success'
|
|
619
|
+
});
|
|
620
|
+
} else if (!createAndCheckoutNewBranch && checkoutExistingBranch) {
|
|
621
|
+
successfulResult.results.push({
|
|
622
|
+
task: 'checkout existing branch',
|
|
623
|
+
result: 'success'
|
|
624
|
+
});
|
|
625
|
+
}
|
|
515
626
|
if (Array.isArray(removeFileOptions.filepath)) {
|
|
516
627
|
return Promise.all(
|
|
517
628
|
removeFileOptions.filepath.map((file) => {
|
package/error.json
CHANGED
|
@@ -96,6 +96,12 @@
|
|
|
96
96
|
"displayString": "Invalid properties: $VARIABLE$",
|
|
97
97
|
"recommendation": "Verify the properties for the adapter"
|
|
98
98
|
},
|
|
99
|
+
{
|
|
100
|
+
"key": "Missing Properties",
|
|
101
|
+
"icode": "AD.306",
|
|
102
|
+
"displayString": "Property $VARIABLE$ is required",
|
|
103
|
+
"recommendation": "Please provide the required property"
|
|
104
|
+
},
|
|
99
105
|
{
|
|
100
106
|
"key": "Query Not Translated",
|
|
101
107
|
"icode": "AD.310",
|
|
@@ -168,6 +174,12 @@
|
|
|
168
174
|
"displayString": "Failure response received for $VARIABLE$",
|
|
169
175
|
"recommendation": "Check the reason for failure in the stack trace"
|
|
170
176
|
},
|
|
177
|
+
{
|
|
178
|
+
"key": "Suspended Adapter",
|
|
179
|
+
"icode": "AD.600",
|
|
180
|
+
"displayString": "Adapter is suspended",
|
|
181
|
+
"recommendation": "Check if external system is functional and unsuspend if appropriate"
|
|
182
|
+
},
|
|
171
183
|
{
|
|
172
184
|
"key": "Caught Exception",
|
|
173
185
|
"icode": "AD.900",
|
package/metadata.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "adapter-git",
|
|
3
|
+
"webName": "Adapter for Integration to Git",
|
|
4
|
+
"vendor": "Git",
|
|
5
|
+
"product": "Git",
|
|
6
|
+
"osVersion": [],
|
|
7
|
+
"apiVersions": [],
|
|
8
|
+
"iapVersions": [
|
|
9
|
+
"2021.1.x",
|
|
10
|
+
"2021.2.x",
|
|
11
|
+
"2022.1.x",
|
|
12
|
+
"2023.1.x"
|
|
13
|
+
],
|
|
14
|
+
"method": "Library",
|
|
15
|
+
"type": "Adapter",
|
|
16
|
+
"domains": [],
|
|
17
|
+
"tags": [],
|
|
18
|
+
"useCases": [],
|
|
19
|
+
"deprecated": {
|
|
20
|
+
"isDeprecated": false
|
|
21
|
+
},
|
|
22
|
+
"brokerSince": "",
|
|
23
|
+
"documentation": {
|
|
24
|
+
"storeLink": "",
|
|
25
|
+
"npmLink": "https://www.npmjs.com/package/@itentialopensource/adapter-git",
|
|
26
|
+
"repoLink": "https://gitlab.com/itentialopensource/adapters/devops-netops/adapter-git.git",
|
|
27
|
+
"docLink": "https://docs.itential.com/opensource/docs/git",
|
|
28
|
+
"demoLinks": [],
|
|
29
|
+
"trainingLinks": [],
|
|
30
|
+
"faqLink": "https://docs.itential.com/opensource/docs/troubleshooting-an-adapter",
|
|
31
|
+
"contributeLink": "https://gitlab.com/itentialopensource/adapters/contributing-guide",
|
|
32
|
+
"issueLink": "https://itential.atlassian.net/servicedesk/customer/portals",
|
|
33
|
+
"webLink": "https://www.itential.com/adapters/git/",
|
|
34
|
+
"vendorLink": "",
|
|
35
|
+
"productLink": "",
|
|
36
|
+
"apiLinks": []
|
|
37
|
+
},
|
|
38
|
+
"assets": [],
|
|
39
|
+
"relatedItems": {
|
|
40
|
+
"adapters": [],
|
|
41
|
+
"integrations": [],
|
|
42
|
+
"ecosystemApplications": [],
|
|
43
|
+
"workflowProjects": [],
|
|
44
|
+
"transformationProjects": [],
|
|
45
|
+
"exampleProjects": []
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Itential adapter to run git commands",
|
|
5
5
|
"main": "adapter.js",
|
|
6
|
-
"wizardVersion": "2.
|
|
7
|
-
"engineVersion": "1.
|
|
6
|
+
"wizardVersion": "2.44.7",
|
|
7
|
+
"engineVersion": "1.67.14",
|
|
8
|
+
"adapterType": "library",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"artifactize": "npm i && node utils/packModificationScript.js",
|
|
10
11
|
"preinstall": "node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
|
|
11
|
-
"
|
|
12
|
+
"deinstall": "node utils/removeHooks.js",
|
|
13
|
+
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
|
|
12
14
|
"lint:errors": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet",
|
|
13
15
|
"test:unit": "mocha test/unit/adapterTestUnit.js --LOG=error",
|
|
14
16
|
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
|
|
@@ -41,30 +43,26 @@
|
|
|
41
43
|
"author": "Itential",
|
|
42
44
|
"homepage": "https://gitlab.com/itentialopensource/adapters/devops-netops/adapter-git#readme",
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"ajv": "^
|
|
46
|
+
"ajv": "^8.12.0",
|
|
45
47
|
"isomorphic-git": "^1.21.0",
|
|
46
48
|
"avsc": "^5.4.21",
|
|
47
|
-
"fs-extra": "^
|
|
49
|
+
"fs-extra": "^11.1.1",
|
|
48
50
|
"json-query": "^2.2.2",
|
|
49
|
-
"package-json-validator": "^0.6.3",
|
|
50
51
|
"patch-package": "^6.4.7",
|
|
51
52
|
"readline-sync": "^1.4.10",
|
|
52
53
|
"request": "^2.88.2",
|
|
53
54
|
"uuid": "^3.0.1"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"chai": "^4.
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"eslint-config-airbnb-base": "^
|
|
59
|
-
"eslint-plugin-import": "^2.
|
|
60
|
-
"eslint-plugin-json": "^
|
|
57
|
+
"chai": "^4.3.7",
|
|
58
|
+
"eslint": "^8.44.0",
|
|
59
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
60
|
+
"eslint-plugin-import": "^2.27.5",
|
|
61
|
+
"eslint-plugin-json": "^3.1.0",
|
|
61
62
|
"mocha": "^9.0.1",
|
|
62
63
|
"nyc": "^15.1.0",
|
|
63
|
-
"testdouble": "^3.
|
|
64
|
+
"testdouble": "^3.18.0",
|
|
64
65
|
"winston": "^3.3.3"
|
|
65
66
|
},
|
|
66
|
-
"resolutions": {
|
|
67
|
-
"minimist": "^1.2.5"
|
|
68
|
-
},
|
|
69
67
|
"private": false
|
|
70
68
|
}
|
package/pronghorn.json
CHANGED
|
@@ -191,10 +191,62 @@
|
|
|
191
191
|
],
|
|
192
192
|
"task": true
|
|
193
193
|
},
|
|
194
|
+
{
|
|
195
|
+
"name": "createBranch",
|
|
196
|
+
"summary": "Create a branch",
|
|
197
|
+
"description": "Create a branch",
|
|
198
|
+
"input": [
|
|
199
|
+
{
|
|
200
|
+
"name": "options",
|
|
201
|
+
"type": "object",
|
|
202
|
+
"info": "options to create a branch",
|
|
203
|
+
"required": true
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"output": {
|
|
207
|
+
"name": "result",
|
|
208
|
+
"type": "object",
|
|
209
|
+
"description": "A JSON Object containing status, code and the result"
|
|
210
|
+
},
|
|
211
|
+
"route": {
|
|
212
|
+
"verb": "POST",
|
|
213
|
+
"path": "/createBranch"
|
|
214
|
+
},
|
|
215
|
+
"roles": [
|
|
216
|
+
"admin"
|
|
217
|
+
],
|
|
218
|
+
"task": true
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "checkoutBranch",
|
|
222
|
+
"summary": "Checkout a branch",
|
|
223
|
+
"description": "Checkout a branch",
|
|
224
|
+
"input": [
|
|
225
|
+
{
|
|
226
|
+
"name": "options",
|
|
227
|
+
"type": "object",
|
|
228
|
+
"info": "options to checkout a branch",
|
|
229
|
+
"required": true
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
"output": {
|
|
233
|
+
"name": "result",
|
|
234
|
+
"type": "object",
|
|
235
|
+
"description": "A JSON Object containing status, code and the result"
|
|
236
|
+
},
|
|
237
|
+
"route": {
|
|
238
|
+
"verb": "POST",
|
|
239
|
+
"path": "/checkoutBranch"
|
|
240
|
+
},
|
|
241
|
+
"roles": [
|
|
242
|
+
"admin"
|
|
243
|
+
],
|
|
244
|
+
"task": true
|
|
245
|
+
},
|
|
194
246
|
{
|
|
195
247
|
"name": "removeAndPushFile",
|
|
196
|
-
"summary": "Clone the repo, remove a file, commit then push",
|
|
197
|
-
"description": "Clone the repo, remove a file, commit then push",
|
|
248
|
+
"summary": "Clone the repo, checkout branch, remove a file, commit then push",
|
|
249
|
+
"description": "Clone the repo, checkout branch, remove a file, commit then push",
|
|
198
250
|
"input": [
|
|
199
251
|
{
|
|
200
252
|
"name": "cloneOptions",
|
|
@@ -202,6 +254,30 @@
|
|
|
202
254
|
"info": "options to clone a repo",
|
|
203
255
|
"required": true
|
|
204
256
|
},
|
|
257
|
+
{
|
|
258
|
+
"name": "createAndCheckoutNewBranch",
|
|
259
|
+
"type": "boolean",
|
|
260
|
+
"info": "whether to create and checkout a new branch",
|
|
261
|
+
"required": false
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "checkoutExistingBranch",
|
|
265
|
+
"type": "boolean",
|
|
266
|
+
"info": "whether to checkout an existing branch",
|
|
267
|
+
"required": false
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"name": "branchOptions",
|
|
271
|
+
"type": "object",
|
|
272
|
+
"info": "options to create a new branch",
|
|
273
|
+
"required": false
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "checkoutOptions",
|
|
277
|
+
"type": "object",
|
|
278
|
+
"info": "options to checkout a branch",
|
|
279
|
+
"required": false
|
|
280
|
+
},
|
|
205
281
|
{
|
|
206
282
|
"name": "removeFileOptions",
|
|
207
283
|
"type": "object",
|
|
Binary file
|
|
@@ -182,6 +182,58 @@ describe('[integration] Git Adapter Test', () => {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
const branchOptions = {
|
|
186
|
+
dir: '../../test',
|
|
187
|
+
ref: 'patch/test'
|
|
188
|
+
};
|
|
189
|
+
describe('#createBranch', () => {
|
|
190
|
+
if (!stub) {
|
|
191
|
+
it('should create a new branch', (done) => {
|
|
192
|
+
try {
|
|
193
|
+
a.createBranch(branchOptions, (data, error) => {
|
|
194
|
+
try {
|
|
195
|
+
runCommonAsserts(data, error);
|
|
196
|
+
assert.equal(200, data.code);
|
|
197
|
+
done();
|
|
198
|
+
} catch (ex) {
|
|
199
|
+
log.error(`Test Failure: ${ex}`);
|
|
200
|
+
done(ex);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
} catch (exc) {
|
|
204
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
205
|
+
done(exc);
|
|
206
|
+
}
|
|
207
|
+
}).timeout(attemptTimeout);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const checkoutOptions = {
|
|
212
|
+
dir: '../../test',
|
|
213
|
+
ref: 'patch/test'
|
|
214
|
+
};
|
|
215
|
+
describe('#checkoutBranch', () => {
|
|
216
|
+
if (!stub) {
|
|
217
|
+
it('should checkout a branch', (done) => {
|
|
218
|
+
try {
|
|
219
|
+
a.checkoutBranch(checkoutOptions, (data, error) => {
|
|
220
|
+
try {
|
|
221
|
+
runCommonAsserts(data, error);
|
|
222
|
+
assert.equal(200, data.code);
|
|
223
|
+
done();
|
|
224
|
+
} catch (ex) {
|
|
225
|
+
log.error(`Test Failure: ${ex}`);
|
|
226
|
+
done(ex);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
} catch (exc) {
|
|
230
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
231
|
+
done(exc);
|
|
232
|
+
}
|
|
233
|
+
}).timeout(attemptTimeout);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
185
237
|
const removeOptions = {
|
|
186
238
|
dir: '../../test',
|
|
187
239
|
filepath: 'README.md'
|
|
@@ -16,6 +16,9 @@ const execute = require('child_process').execSync;
|
|
|
16
16
|
const { expect } = require('chai');
|
|
17
17
|
const { use } = require('chai');
|
|
18
18
|
const td = require('testdouble');
|
|
19
|
+
const Ajv = require('ajv');
|
|
20
|
+
|
|
21
|
+
const ajv = new Ajv({ strictSchema: false, allErrors: true, allowUnionTypes: true });
|
|
19
22
|
|
|
20
23
|
const anything = td.matchers.anything();
|
|
21
24
|
|
|
@@ -134,7 +137,7 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
134
137
|
|
|
135
138
|
mocha.afterEach(function x() {
|
|
136
139
|
state.passed = state.passed
|
|
137
|
-
|
|
140
|
+
&& (this.currentTest.state === 'passed');
|
|
138
141
|
});
|
|
139
142
|
mocha.beforeEach(function x() {
|
|
140
143
|
if (!state.passed) {
|
|
@@ -171,23 +174,33 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
171
174
|
});
|
|
172
175
|
});
|
|
173
176
|
it('package.json should be validated', (done) => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
try {
|
|
178
|
+
const packageDotJson = require('../../package.json');
|
|
179
|
+
// Define the JSON schema for package.json
|
|
180
|
+
const packageJsonSchema = {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
name: { type: 'string' },
|
|
184
|
+
version: { type: 'string' }
|
|
185
|
+
// May need to add more properties as needed
|
|
186
|
+
},
|
|
187
|
+
required: ['name', 'version']
|
|
188
|
+
};
|
|
189
|
+
const validate = ajv.compile(packageJsonSchema);
|
|
190
|
+
const isValid = validate(packageDotJson);
|
|
191
|
+
|
|
192
|
+
if (isValid === false) {
|
|
193
|
+
log.error('The package.json contains errors');
|
|
194
|
+
assert.equal(true, isValid);
|
|
195
|
+
} else {
|
|
196
|
+
assert.equal(true, isValid);
|
|
197
|
+
}
|
|
189
198
|
|
|
190
|
-
|
|
199
|
+
done();
|
|
200
|
+
} catch (error) {
|
|
201
|
+
log.error(`Test Failure: ${error}`);
|
|
202
|
+
done(error);
|
|
203
|
+
}
|
|
191
204
|
});
|
|
192
205
|
it('package.json should be customized', (done) => {
|
|
193
206
|
const packageDotJson = require('../../package.json');
|
|
@@ -244,10 +257,10 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
244
257
|
|
|
245
258
|
// if there are inputs defined but not on the method line
|
|
246
259
|
if (wfparams.length === 0 && (pronghornDotJson.methods[m].input
|
|
247
|
-
|
|
260
|
+
&& pronghornDotJson.methods[m].input.length > 0)) {
|
|
248
261
|
paramissue = true;
|
|
249
262
|
} else if (wfparams.length > 0 && (!pronghornDotJson.methods[m].input
|
|
250
|
-
|
|
263
|
+
|| pronghornDotJson.methods[m].input.length === 0)) {
|
|
251
264
|
// if there are no inputs defined but there are on the method line
|
|
252
265
|
paramissue = true;
|
|
253
266
|
} else {
|
|
@@ -551,6 +564,54 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
551
564
|
}).timeout(attemptTimeout);
|
|
552
565
|
});
|
|
553
566
|
|
|
567
|
+
describe('#createBranch - errors', () => {
|
|
568
|
+
it('should have a createBranch function', (done) => {
|
|
569
|
+
assert.equal(true, typeof a.createBranch === 'function');
|
|
570
|
+
done();
|
|
571
|
+
});
|
|
572
|
+
it('should error on createBranch - no options', (done) => {
|
|
573
|
+
try {
|
|
574
|
+
a.createBranch(null, (data, error) => {
|
|
575
|
+
try {
|
|
576
|
+
const displayE = 'options is required';
|
|
577
|
+
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-createBranch', displayE);
|
|
578
|
+
done();
|
|
579
|
+
} catch (ex) {
|
|
580
|
+
log.error(`Test Failure: ${ex}`);
|
|
581
|
+
done(ex);
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
} catch (exc) {
|
|
585
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
586
|
+
done(exc);
|
|
587
|
+
}
|
|
588
|
+
}).timeout(attemptTimeout);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
describe('#checkoutBranch - errors', () => {
|
|
592
|
+
it('should have a checkoutBranch function', (done) => {
|
|
593
|
+
assert.equal(true, typeof a.checkoutBranch === 'function');
|
|
594
|
+
done();
|
|
595
|
+
});
|
|
596
|
+
it('should error on checkoutBranch - no options', (done) => {
|
|
597
|
+
try {
|
|
598
|
+
a.checkoutBranch(null, (data, error) => {
|
|
599
|
+
try {
|
|
600
|
+
const displayE = 'options is required';
|
|
601
|
+
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-checkoutBranch', displayE);
|
|
602
|
+
done();
|
|
603
|
+
} catch (ex) {
|
|
604
|
+
log.error(`Test Failure: ${ex}`);
|
|
605
|
+
done(ex);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
} catch (exc) {
|
|
609
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
610
|
+
done(exc);
|
|
611
|
+
}
|
|
612
|
+
}).timeout(attemptTimeout);
|
|
613
|
+
});
|
|
614
|
+
|
|
554
615
|
describe('#removeAndPushFile - errors', () => {
|
|
555
616
|
it('should have a removeAndPushFile function', (done) => {
|
|
556
617
|
assert.equal(true, typeof a.removeAndPushFile === 'function');
|
|
@@ -558,7 +619,7 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
558
619
|
});
|
|
559
620
|
it('should error on removeAndPushFile - no cloneOptions', (done) => {
|
|
560
621
|
try {
|
|
561
|
-
a.removeAndPushFile(null, null, null, null, (data, error) => {
|
|
622
|
+
a.removeAndPushFile(null, null, null, null, null, null, null, null, (data, error) => {
|
|
562
623
|
try {
|
|
563
624
|
const displayE = 'clone options is required';
|
|
564
625
|
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-removeAndPushFile', displayE);
|
|
@@ -575,7 +636,7 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
575
636
|
}).timeout(attemptTimeout);
|
|
576
637
|
it('should error on removeAndPushFile - no removeFileOptions', (done) => {
|
|
577
638
|
try {
|
|
578
|
-
a.removeAndPushFile({}, null, null, null, (data, error) => {
|
|
639
|
+
a.removeAndPushFile({}, null, null, null, null, null, null, null, (data, error) => {
|
|
579
640
|
try {
|
|
580
641
|
const displayE = 'remove file options is required';
|
|
581
642
|
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-removeAndPushFile', displayE);
|
|
@@ -592,7 +653,7 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
592
653
|
}).timeout(attemptTimeout);
|
|
593
654
|
it('should error on removeAndPushFile - no commitOptions', (done) => {
|
|
594
655
|
try {
|
|
595
|
-
a.removeAndPushFile({}, {}, null, null, (data, error) => {
|
|
656
|
+
a.removeAndPushFile({}, null, null, null, null, {}, null, null, (data, error) => {
|
|
596
657
|
try {
|
|
597
658
|
const displayE = 'commit options is required';
|
|
598
659
|
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-removeAndPushFile', displayE);
|
|
@@ -609,7 +670,7 @@ describe('[unit] Git Adapter Test', () => {
|
|
|
609
670
|
}).timeout(attemptTimeout);
|
|
610
671
|
it('should error on removeAndPushFile - no pushOptions', (done) => {
|
|
611
672
|
try {
|
|
612
|
-
a.removeAndPushFile({}, {}, {}, null, (data, error) => {
|
|
673
|
+
a.removeAndPushFile({}, null, null, null, null, {}, {}, null, (data, error) => {
|
|
613
674
|
try {
|
|
614
675
|
const displayE = 'push options is required';
|
|
615
676
|
runErrorAsserts(data, error, 'AD.300', 'Test-Git-adapter-removeAndPushFile', displayE);
|