Skip to content

Commit

Permalink
feat: fix gitlab tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrada Nyirestyan <andrada.nyirestyan@snyk.io>
  • Loading branch information
bengro authored and andradanyirestyan committed Sep 18, 2023
1 parent 6980abd commit a435ce5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/lib/source-handlers/gitlab/list-repos.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('listGitlabRepos', () => {
const GITLAB_ORG_NAME = process.env.TEST_GITLAB_ORG_NAME;
process.env.GITLAB_TOKEN = process.env.TEST_GITLAB_TOKEN;
// shared-with-group project is shared with group snyk-test
const gitlabGroupName = 'snyk-test';
const gitlabGroupName = 'another-group-for-contract-tests';
const repos = await listGitlabRepos(gitlabGroupName, GITLAB_BASE_URL);
expect(
repos.filter((r) => r.name === `${GITLAB_ORG_NAME}/shared-with-group`),
Expand All @@ -42,7 +42,7 @@ describe('listGitlabRepos', () => {
it('list repos for a sub-group', async () => {
const GITLAB_BASE_URL = process.env.TEST_GITLAB_BASE_URL;
process.env.GITLAB_TOKEN = process.env.TEST_GITLAB_TOKEN;
const gitlabGroupName = 'snyk-fixtures/example-sub-group';
const gitlabGroupName = 'snyk-api-import-contract-tests/example-sub-group';
const repos = await listGitlabRepos(gitlabGroupName, GITLAB_BASE_URL);
expect(repos.length > 0).toBeTruthy();
}, 10000);
Expand Down
6 changes: 3 additions & 3 deletions test/scripts/fixtures/import-projects-gitlab.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"orgId": "74e2f385-a54f-491e-9034-76c53e72927a",
"integrationId": "c1285fdd-fad5-472e-b515-127b60900965",
"target": {
"name": "test-maven",
"branch": "develop",
"id": 226,
"name": "snyk-api-import-contract-tests/project-from-template",
"branch": "master",
"id": 28,
"fork": false
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/scripts/import-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('Import projects script', () => {
path.resolve(__dirname + `/fixtures/import-projects-gitlab.json`),
__dirname,
);

expect(projects).not.toBe([]);
expect(projects[0]).toMatchObject({
projectUrl: expect.any(String),
Expand All @@ -70,7 +71,7 @@ describe('Import projects script', () => {
const logFile = fs.readFileSync(logFiles.importLogPath, 'utf8');
// Gitlab project
expect(logFile).toMatch(
`"target":{"name":"test-maven","branch":"develop"}`,
`"target":{"name":"snyk-api-import-contract-tests/project-from-template","branch":"master"}`,
);
discoveredProjects.push(...projects);
}, 2400000);
Expand Down
2 changes: 1 addition & 1 deletion test/system/fixtures/org-data/orgs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"orgData": [
{
"name": "snyk-fixtures",
"name": "snyk-api-import-contract-tests",
"orgId": "<snyk_org_id>",
"integrations": {
"gitlab": "<snyk_org_integration_id>"
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('General `snyk-api-import orgs:data <...>`', () => {
expect(stderr).toEqual('');
expect(err).toBeNull();
expect(stdout).toMatch(
'Found 15 group(s). Written the data to file: group-hello-gitlab-orgs.json',
'Found 3 group(s). Written the data to file: group-hello-gitlab-orgs.json',
);
deleteFiles([
path.resolve(__dirname, `group-${groupId}-gitlab-orgs.json`),
Expand Down

0 comments on commit a435ce5

Please sign in to comment.