35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { tap, expect } from '@push.rocks/tapbundle';
|
|
import * as qenv from '@push.rocks/qenv';
|
|
import { GitLabClient } from '../ts/index.js';
|
|
|
|
const testQenv = new qenv.Qenv('./', '.nogit/');
|
|
|
|
let gitlabClient: GitLabClient;
|
|
|
|
tap.test('should create a GitLabClient instance', async () => {
|
|
const baseUrl = (await testQenv.getEnvVarOnDemand('GITLAB_BASE_URL')) || 'https://gitlab.com';
|
|
const token = (await testQenv.getEnvVarOnDemand('GITLAB_TOKEN')) || '';
|
|
gitlabClient = new GitLabClient(baseUrl, token);
|
|
expect(gitlabClient).toBeInstanceOf(GitLabClient);
|
|
});
|
|
|
|
tap.test('should test connection', async () => {
|
|
const result = await gitlabClient.testConnection();
|
|
expect(result).toHaveProperty('ok');
|
|
console.log('Connection test:', result);
|
|
});
|
|
|
|
tap.test('should get projects', async () => {
|
|
const projects = await gitlabClient.getProjects({ perPage: 5 });
|
|
expect(projects).toBeArray();
|
|
console.log(`Found ${projects.length} projects`);
|
|
});
|
|
|
|
tap.test('should get groups', async () => {
|
|
const groups = await gitlabClient.getGroups({ perPage: 5 });
|
|
expect(groups).toBeArray();
|
|
console.log(`Found ${groups.length} groups`);
|
|
});
|
|
|
|
export default tap.start();
|