Skip to content

Commit b57b2f3

Browse files
committed
Solve issues with login.
1 parent a67db46 commit b57b2f3

1 file changed

Lines changed: 9 additions & 30 deletions

File tree

src/test/api.integration.spec.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,24 @@ const user = process.env.API_USER;
99
const password = process.env.API_PASSWORD;
1010
const baseURL = process.env.API_BASE_URL || 'https://dashboard.metacall.io';
1111

12-
let MaybeAPI: API | undefined = undefined;
13-
14-
describe('Login API', function () {
15-
if (user === undefined || password === undefined) {
16-
// Skip test
17-
console.warn(
18-
'⚠️ Warning: Login API Test being skipped due to API_USER or API_PASSWORD not defined'
19-
);
20-
return;
21-
}
22-
23-
it('Should login', async function () {
24-
const token = await login(user, password, baseURL);
25-
MaybeAPI = Protocol(token, baseURL);
26-
});
27-
});
28-
2912
describe('Integration API', function () {
3013
this.timeout(2000000);
3114

32-
if (MaybeAPI === undefined) {
33-
if (user === undefined || password === undefined) {
34-
// Skip test
15+
let API: API;
16+
17+
before(async function () {
18+
if (!user || !password) {
19+
// Skip all tests
3520
console.warn(
3621
'⚠️ Warning: Login API Test being skipped due to API_USER or API_PASSWORD not defined'
3722
);
38-
return;
39-
} else {
40-
throw Error('Login failed');
23+
this.skip();
4124
}
42-
}
43-
44-
const API: API = MaybeAPI;
25+
const token = await login(user, password, baseURL);
26+
API = Protocol(token, baseURL);
27+
});
4528

4629
it('Should deploy a repository', async function () {
47-
if (API === undefined) {
48-
throw Error('Invalid login');
49-
}
50-
5130
const { id } = await API.add(
5231
'https://github.com/metacall/examples.git',
5332
'master',

0 commit comments

Comments
 (0)