Skip to content

Commit

Permalink
Merge pull request #138 from port-labs/fix-tests
Browse files Browse the repository at this point in the history
Fix Tests
  • Loading branch information
omby8888 authored Nov 20, 2024
2 parents f6ce734 + 887ba5c commit 40e774d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/__tests__/bulk-upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, getInput, setInputs } from './utils/utils';

describe('Bulk Upsert Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand Down Expand Up @@ -39,8 +41,7 @@ describe('Bulk Upsert Integration Tests', () => {
...{
operation: 'BULK_UPSERT',
entities:
'[{"title": "GH Action Test Identity", "icon": "GH Action Test Identity", "blueprint": "gh-action-test-bp", "team": ["Test"],"properties": {"text": "test","number": 1,"boolean": true, "array": [1,2],"object": { "foo": "bar" } },"relations": { "gha-relation": "test"}, "runId": "r_eeUY1AJKzQeaywfv"}]',
runId: 'r_eeUY1AJKzQeaywfv',
'[{"title": "GH Action Test Identity", "icon": "GH Action Test Identity", "blueprint": "gh-action-test-bp", "team": ["Test"],"properties": {"text": "test","number": 1,"boolean": true, "array": [1,2],"object": { "foo": "bar" } },"relations": { "gha-relation": "test"}}]',
},
};

Expand Down Expand Up @@ -82,6 +83,5 @@ describe('Bulk Upsert Integration Tests', () => {
await main();

expect(outputMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith('Unexpected token ] in JSON at position 2');
});
});
2 changes: 2 additions & 0 deletions src/__tests__/create-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, setInputs } from './utils/utils';

describe('Create Run Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, getInput, setInputs } from './utils/utils';

describe('Get Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand All @@ -24,7 +26,7 @@ describe('Get Integration Tests', () => {
const parentEntityToUpsert = {
identifier: 'delete_test_parent',
title: 'GH Action Test Identity Delete Parent',
icon: 'GH Action Test Identity',
icon: 'Microservice',
blueprint: 'gh-action-test-bp2',
team: [],
properties: {},
Expand All @@ -34,7 +36,7 @@ describe('Get Integration Tests', () => {
const childEntityToUpsert = {
identifier: 'delete_test_child',
title: 'GH Action Test Identity Delete Child',
icon: 'GH Action Test Identity',
icon: 'Microservice',
blueprint: 'gh-action-test-bp',
team: [],
properties: {},
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, setInputs } from './utils/utils';

describe('Get Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand Down
10 changes: 6 additions & 4 deletions src/__tests__/patch-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, setInputs } from './utils/utils';

describe('Patch Run Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand All @@ -24,7 +26,7 @@ describe('Patch Run Integration Tests', () => {
...getBaseInput(),
...{
operation: 'PATCH_RUN',
runId: 'r_eeUY1AJKzQeaywfv',
runId: 'r_OsJdfkZvZQxGI8Dr',
logMessage: 'Test message',
},
};
Expand All @@ -44,7 +46,7 @@ describe('Patch Run Integration Tests', () => {
...getBaseInput(),
...{
operation: 'PATCH_RUN',
runId: 'r_eeUY1AJKzQeaywfv',
runId: 'r_OsJdfkZvZQxGI8Dr',
logMessage: 'Test message',
link: `["https://www.google.com","https://www.google.com"]`,
},
Expand All @@ -63,7 +65,7 @@ describe('Patch Run Integration Tests', () => {
...getBaseInput(),
...{
operation: 'PATCH_RUN',
runId: 'r_oNfB7XpORwwJqvd8',
runId: 'r_GlgkML4bonUb7S89',
status: 'SUCCESS',
},
};
Expand Down Expand Up @@ -98,7 +100,7 @@ describe('Patch Run Integration Tests', () => {
...getBaseInput(),
...{
operation: 'PATCH_RUN',
runId: 'r_oB7y1xUZY37J6uRU',
runId: 'r_OsJdfkZvZQxGI8Dr',
status: 'INVALID',
},
};
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, setInputs } from './utils/utils';

describe('Search Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import main from '../main';
import { TestInputs, clearInputs, getBaseInput, getInput, setInputs } from './utils/utils';

describe('Upsert Integration Tests', () => {
jest.setTimeout(100000);

let outputMock: jest.SpyInstance;
let failedMock: jest.SpyInstance;
let input: TestInputs = {};
Expand Down Expand Up @@ -40,7 +42,7 @@ describe('Upsert Integration Tests', () => {
...{
operation: 'UPSERT',
title: 'GH Action Test Identity',
icon: 'GH Action Test Identity',
icon: 'Microservice',
blueprint: 'gh-action-test-bp',
team: '["Test"]',
properties: '{"text": "test", "number": 1, "boolean": true, "array": [1, 2], "object": {"foo": "bar"}}',
Expand Down
2 changes: 0 additions & 2 deletions src/clients/port/upsertEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const upsertEntity = async (
baseUrl: string,
accessToken: string,
entity: EntityToUpsert,
options: Partial<{ runId: string }> = {},
): Promise<Entity> => {
const url = `${baseUrl}/v1/blueprints/${entity.blueprint}/entities`;
try {
Expand All @@ -20,7 +19,6 @@ const upsertEntity = async (
params: {
upsert: true,
merge: true,
...(options.runId && { run_id: options.runId }),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export default class EntityBulkUpserter implements IOperation {
const accessToken = await clients.port.getToken(this.input.baseUrl, this.input.clientId, this.input.clientSecret);

for (const entityToUpsert of entitiesToUpsert.entities) {
const entityRes = await clients.port.upsertEntity(this.input.baseUrl, accessToken, entityToUpsert, {
runId: this.input.runId,
});

const entityRes = await clients.port.upsertEntity(this.input.baseUrl, accessToken, entityToUpsert);
entitiesRes.push(entityRes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export default class EntityUpserterOperation implements IOperation {
execute = async (): Promise<Record<string, any>> => {
const entityToUpsert = this.parseInput();
const accessToken = await clients.port.getToken(this.input.baseUrl, this.input.clientId, this.input.clientSecret);
const entityRes = await clients.port.upsertEntity(this.input.baseUrl, accessToken, entityToUpsert, {
runId: this.input.runId,
});
const entityRes = await clients.port.upsertEntity(this.input.baseUrl, accessToken, entityToUpsert);

return {
identifier: entityRes.identifier,
Expand Down

0 comments on commit 40e774d

Please sign in to comment.