Skip to content

Commit 849b90c

Browse files
reggeenrGitHub Enterprise
authored andcommitted
fix(tests): enabled the v2 integration test suite (#11)
* fix(tests): enabled the v2 integration test suite * fix(tests): adjusted the integration tests * fix(tests): adjusted the unit test targeit for travis checks * adjusted the integration run script * ignore generated int tests * adjusted public travis config
1 parent 906960b commit 849b90c

File tree

9 files changed

+1108
-205
lines changed

9 files changed

+1108
-205
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ node_modules/
77
examples/**/node_modules/
88
!examples/**/*.js
99
example/*.js
10+
examples/*.js
1011
example/**/node_modules/
1112
scripts/*.js
1213

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,8 @@ secrets.tar
8484
# SDK generator
8585
.openapi-generator*
8686

87-
.npmrc
87+
.npmrc
88+
89+
# ignore the generated integration test files, as they cannot be used without manual editing
90+
test/integration/code-engine.v1.test.js
91+
test/integration/code-engine.v2.test.js

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ group: beta
55

66
language: node_js
77
node_js:
8-
- 14
9-
- 16
108
- 18
119

1210
branches:
@@ -18,10 +16,15 @@ branches:
1816
before_install:
1917
- npm i -g npm@8
2018
- npm --version
19+
# create an .env file that is pulled in while executing the v2 integration tests
20+
- echo "CODE_ENGINE_URL=https://$CE_API_HOST/v2" > code_engine_v2.env
21+
- echo "CODE_ENGINE_AUTH_TYPE=iam" >> code_engine_v2.env
22+
- echo "CODE_ENGINE_APIKEY=$CE_API_KEY" >> code_engine_v2.env
23+
- echo "CODE_ENGINE_AUTH_URL=$IAM_ENDPOINT" >> code_engine_v2.env
2124

2225
script:
2326
- npm run build
24-
- npm run test-travis || travis_terminate 1
27+
- npm run test-unit-travis || travis_terminate 1
2528
- npm run lint
2629
- npm run check-packages
2730
- npm run test-integration-travis || travis_terminate 1

.travis_public.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
dist: focal
2+
3+
language: node_js
4+
node_js:
5+
- 18
6+
cache: npm
7+
8+
branches:
9+
only:
10+
- main
11+
12+
jobs:
13+
include:
14+
- stage: verify
15+
install:
16+
- npm install
17+
script:
18+
- npm run build
19+
- npm run test-unit-travis || travis_terminate 1
20+
- npm run lint
21+
- npm run check-packages

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
"jest": "jest",
2323
"test": "npm run build && npm run lint && jest test/",
2424
"test-unit": "npm run build && jest test/unit/",
25-
"test-integration": "jest --runInBand test/integration/",
25+
"test-integration": "jest --testPathIgnorePatterns '^(.*/code-engine.v2.test.js)$' --runInBand test/integration/",
2626
"test-examples": "npm run build && jest examples/",
2727
"test-travis": "jest --runInBand --testNamePattern='^((?!@slow).)*$' test/",
2828
"test-unit-travis": "jest --runInBand test/unit/",
29-
"test-integration-travis": "jest --runInBand --no-colors --testNamePattern='^((?!@slow).)*$' --json test/integration > test-output.log",
29+
"test-integration-travis": "jest --testPathIgnorePatterns '^(.*/code-engine.v2.test.js)$' --runInBand test/integration",
3030
"check-packages": "installed-check -e -d -v",
3131
"all": "npm run test-unit && npm run lint"
3232
},

prepare_project.sh

Lines changed: 0 additions & 99 deletions
This file was deleted.

test/integration/code-engine.v2.test.js

Lines changed: 0 additions & 100 deletions
This file was deleted.

test/integration/v1.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/* eslint-disable no-console */
18+
19+
const { readExternalSources } = require('ibm-cloud-sdk-core');
20+
const CodeEngineV1 = require('../../dist/ibm-cloud-code-engine/v1');
21+
const authHelper = require('../resources/auth-helper.js');
22+
23+
// testcase timeout value (200s).
24+
const timeout = 200000;
25+
26+
// Location of our config file.
27+
const configFile = 'code_engine_v1.env';
28+
29+
const describe = authHelper.prepareTests(configFile);
30+
31+
describe('CodeEngineV1_integration', () => {
32+
jest.setTimeout(timeout);
33+
34+
// Service instance
35+
let codeEngineService;
36+
37+
test('Initialize service', async () => {
38+
codeEngineService = CodeEngineV1.newInstance();
39+
40+
expect(codeEngineService).not.toBeNull();
41+
42+
const config = readExternalSources(CodeEngineV1.DEFAULT_SERVICE_NAME);
43+
expect(config).not.toBeNull();
44+
45+
codeEngineService.enableRetries();
46+
});
47+
48+
test('projectConfigGet()', async () => {
49+
const params = {
50+
xDelegatedRefreshToken: 'testString',
51+
projectGuid: 'testString',
52+
endpoint: 'testString',
53+
};
54+
55+
const res = await codeEngineService.projectConfigGet(params);
56+
expect(res).toBeDefined();
57+
expect(res.status).toBe(200);
58+
expect(res.result).toBeDefined();
59+
});
60+
});

0 commit comments

Comments
 (0)