Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel committed Jan 15, 2025
1 parent 7e84ea9 commit db2cfd8
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 1,721 deletions.
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/runner/lib/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import tracer from 'dd-trace';
import { errorToObject, metrics, truncateJson } from '@nangohq/utils';
import { logger } from './utils.js';
import type { NangoProps, RunnerOutput } from '@nangohq/types';
import { instrumentSDK, NangoActionRunner, NangoSyncRunner } from './sdk.js';
import { instrumentSDK, NangoActionRunner, NangoSyncRunner } from './sdk/sdk.js';
import { ActionError, SDKError, validateData } from '@nangohq/runner-sdk';

export async function exec(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { expect, describe, it, beforeAll } from 'vitest';
import { multipleMigrations } from '@nangohq/database';
import type { Connection } from '../models/Connection.js';
import type { NangoProps } from './sync.js';
import { NangoAction } from './sync.js';
import connectionService from '../services/connection.service.js';
import environmentService from '../services/environment.service.js';
import { createConnectionSeeds } from '../seeders/connection.seeder.js';
import { createConfigSeeds } from '../seeders/config.seeder.js';
import { createEnvironmentSeed } from '../seeders/environment.seeder.js';
import type { DBEnvironment, DBSyncConfig } from '@nangohq/types';
import type { Connection } from '@nangohq/shared/lib/models/Connection.js';
import connectionService from '@nangohq/shared/lib/services/connection.service.js';
import environmentService from '@nangohq/shared/lib/services/environment.service.js';
import { createConnectionSeeds } from '@nangohq/shared/lib/seeders/connection.seeder.js';
import { createConfigSeeds } from '@nangohq/shared/lib/seeders/config.seeder.js';
import { createEnvironmentSeed } from '@nangohq/shared/lib/seeders/environment.seeder.js';
import type { DBEnvironment, DBSyncConfig, NangoProps } from '@nangohq/types';
import { NangoActionRunner } from './sdk.js';

describe('Connection service integration tests', () => {
let env: DBEnvironment;
Expand Down Expand Up @@ -60,7 +59,7 @@ describe('Connection service integration tests', () => {
endUser: null
};

const nango = new NangoAction(nangoProps);
const nango = new NangoActionRunner(nangoProps);

// @ts-expect-error we are overriding a private method here
nango.nango.getConnection = async (providerConfigKey: string, connectionId: string) => {
Expand Down
9 changes: 9 additions & 0 deletions packages/runner/lib/sdk.ts → packages/runner/lib/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export class NangoActionRunner extends NangoActionBase {
interceptors: { response: { onFulfilled: this.logAPICall.bind(this) } }
}
);

if (!this.activityLogId) throw new Error('Parameter activityLogId is required when not in dryRun');
if (!this.environmentId) throw new Error('Parameter environmentId is required when not in dryRun');
if (!this.nangoConnectionId) throw new Error('Parameter nangoConnectionId is required when not in dryRun');
if (!this.syncConfig) throw new Error('Parameter syncConfig is required when not in dryRun');
}

public override async proxy<T = any>(config: ProxyConfiguration): Promise<AxiosResponse<T>> {
Expand Down Expand Up @@ -134,6 +139,7 @@ export class NangoActionRunner extends NangoActionBase {
}

public triggerSync(providerConfigKey: string, connectionId: string, syncName: string, fullResync?: boolean): Promise<void | string> {
this.throwIfAborted();
return this.nango.triggerSync(providerConfigKey, [syncName], connectionId, fullResync);
}

Expand Down Expand Up @@ -243,6 +249,9 @@ export class NangoSyncRunner extends NangoSyncBase {
interceptors: { response: { onFulfilled: this.logAPICall.bind(this) } }
}
);

if (!this.syncId) throw new Error('Parameter syncId is required when not in dryRun');
if (!this.syncJobId) throw new Error('Parameter syncJobId is required when not in dryRun');
}

// Can't double extends
Expand Down
Loading

0 comments on commit db2cfd8

Please sign in to comment.