Provides GiteaClient class with methods for repos, orgs, secrets, and action runs.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { tap, expect } from '@push.rocks/tapbundle';
|
|
import * as qenv from '@push.rocks/qenv';
|
|
import { GiteaClient } from '../ts/index.js';
|
|
|
|
const testQenv = new qenv.Qenv('./', '.nogit/');
|
|
|
|
let giteaClient: GiteaClient;
|
|
|
|
tap.test('should create a GiteaClient instance', async () => {
|
|
const baseUrl = testQenv.getEnvVarOnDemand('GITEA_BASE_URL') || 'https://gitea.lossless.digital';
|
|
const token = testQenv.getEnvVarOnDemand('GITEA_TOKEN') || '';
|
|
giteaClient = new GiteaClient(baseUrl, token);
|
|
expect(giteaClient).toBeInstanceOf(GiteaClient);
|
|
});
|
|
|
|
tap.test('should test connection', async () => {
|
|
const result = await giteaClient.testConnection();
|
|
expect(result).toHaveProperty('ok');
|
|
console.log('Connection test:', result);
|
|
});
|
|
|
|
tap.test('should get repos', async () => {
|
|
const repos = await giteaClient.getRepos({ perPage: 5 });
|
|
expect(repos).toBeArray();
|
|
console.log(`Found ${repos.length} repos`);
|
|
});
|
|
|
|
tap.test('should get orgs', async () => {
|
|
const orgs = await giteaClient.getOrgs({ perPage: 5 });
|
|
expect(orgs).toBeArray();
|
|
console.log(`Found ${orgs.length} orgs`);
|
|
});
|
|
|
|
export default tap.start();
|