mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-18 15:55:30 +00:00
- Updating CI script to use latest shutdown logic - Removed unneeded tests - Split browser tests into ones that need a Gitlab instance those that down - Removing the need to run the full e2e test unless its a release branch - Moved the most tested release tests (the exports) into a integration test since it doesnt require a full Gitlab instance for testing
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import { Projects } from '../../../../src';
|
|
|
|
const { GITLAB_PERSONAL_ACCESS_TOKEN = '', GITLAB_URL = '', TEST_ID = Date.now() } = process.env;
|
|
|
|
let service: InstanceType<typeof Projects<false>>;
|
|
|
|
beforeEach(() => {
|
|
service = new Projects({
|
|
host: GITLAB_URL,
|
|
token: GITLAB_PERSONAL_ACCESS_TOKEN,
|
|
});
|
|
});
|
|
|
|
describe('Projects.create', () => {
|
|
it('should create a valid project', async () => {
|
|
const name = `Project Creation Integration Test - NODEJS ${TEST_ID}`;
|
|
const p = await service.create({ name });
|
|
|
|
expect(p).toBeObject();
|
|
expect(p.name).toEqual(name);
|
|
});
|
|
});
|
|
|
|
describe('Projects.all', () => {
|
|
beforeAll(async () => {
|
|
const newProjects: any[] = [];
|
|
|
|
for (let i = 0; i < 10; i += 1) {
|
|
newProjects.push(
|
|
service.create({ name: `Project All Integration Test - NODEJS ${TEST_ID} ${i}` }),
|
|
);
|
|
}
|
|
|
|
await Promise.all(newProjects);
|
|
}, 60000);
|
|
|
|
it('should get 10 projects using offset pagination', async () => {
|
|
const projects = await service.all({
|
|
pagination: 'offset',
|
|
maxPages: 2,
|
|
perPage: 5,
|
|
simple: true,
|
|
});
|
|
|
|
expect(projects).toBeArray();
|
|
expect(projects).toHaveLength(10);
|
|
});
|
|
|
|
it('should timeout with a short queryTimeout', async () => {
|
|
const timedService = new Projects({
|
|
host: GITLAB_URL,
|
|
token: GITLAB_PERSONAL_ACCESS_TOKEN,
|
|
queryTimeout: 200,
|
|
});
|
|
|
|
await expect(() =>
|
|
timedService.all({
|
|
pagination: 'offset',
|
|
simple: true,
|
|
}),
|
|
).rejects.toThrow('Query timeout was reached');
|
|
});
|
|
});
|
|
|
|
describe('Projects.uploadForReference', () => {
|
|
it('should upload a text file', async () => {
|
|
const project = await service.create({
|
|
name: `Project Upload Integration Test Text File - NodeJS ${TEST_ID}`,
|
|
});
|
|
|
|
const blob = new Blob(['TESTING FILE UPLOAD'], {
|
|
type: 'text/plain',
|
|
});
|
|
|
|
const results = await service.uploadForReference(project.id, {
|
|
content: blob,
|
|
filename: 'testfile.txt',
|
|
});
|
|
|
|
expect(results).toContainKeys(['alt', 'url', 'full_path', 'markdown']);
|
|
});
|
|
});
|