Skip to content

Commit

Permalink
Fixes integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-gerber committed May 16, 2023
1 parent 8ee61cf commit 1ef3b63
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ jobs:
echo "Faros init container exit code was ${CONTAINER_EXIT_CODE}"
[[ $CONTAINER_EXIT_CODE -eq 0 ]]
- name: Get destination id & Hasura Admin Secret
- name: Get Hasura Admin Secret
run: |
echo "DESTINATION_ID=$(cat ${{ github.workspace }}/init/resources/airbyte/workspace/airbyte_config/DESTINATION_CONNECTION.yaml | yq '.[0].destinationId')" >> "$GITHUB_ENV"
echo $(cat .env | grep "^HASURA_GRAPHQL_ADMIN_SECRET") >> "$GITHUB_ENV"
- name: Run integration tests (init)
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ jobs:
echo "Faros init container exit code was ${CONTAINER_EXIT_CODE}"
[[ $CONTAINER_EXIT_CODE -eq 0 ]]
- name: Get destination id & Hasura Admin Secret
- name: Get Hasura Admin Secret
run: |
echo "DESTINATION_ID=$(cat ${{ github.workspace }}/init/resources/airbyte/workspace/airbyte_config/DESTINATION_CONNECTION.yaml | yq '.[0].destinationId')" >> "$GITHUB_ENV"
echo $(cat .env | grep "^HASURA_GRAPHQL_ADMIN_SECRET") >> "$GITHUB_ENV"
- name: Run integration tests (init)
Expand Down
34 changes: 19 additions & 15 deletions init/test/integration-tests/airbyte-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,28 @@ export class AirbyteClient {
);
}

async checkDestinationConnection(destinationId: string): Promise<boolean> {
return await this.api
.post('/destinations/check_connection', {
destinationId,
})
.then((response) => response.data.status === 'succeeded');
async getFirstWorkspace(): Promise<string> {
const response = await this.api.post('/workspaces/list', {});
return response.data.workspaces[0].workspaceId as string;
}

async checkDestinationConnection(destinationName: string): Promise<boolean> {
const workspaceId = await this.getFirstWorkspace();
const response = await this.api.post('/destinations/list', {workspaceId});
return (
response.data.destinations.filter(
(destination) => destination.name === destinationName
).length > 0
);
}

async getDestinationConnectionConfiguration(
destinationId: string
destinationName: string
): Promise<ConnectionConfiguration> {
return await this.api
.post('/destinations/get', {
destinationId,
})
.then(
(response) =>
response.data.connectionConfiguration as ConnectionConfiguration
);
const workspaceId = await this.getFirstWorkspace();
const response = await this.api.post('/destinations/list', {workspaceId});
return response.data.destinations.filter(
(destination) => destination.name === destinationName
)[0].connectionConfiguration as ConnectionConfiguration;
}
}
6 changes: 2 additions & 4 deletions init/test/integration-tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import path from 'path';
import {AirbyteClient, ConnectionConfiguration} from './airbyte-client';
import {HasuraClient} from './hasura-client';

let destinationId: string;
let hasuraAdminSecret: string;
let hasuraClient: HasuraClient;
let airbyteClient: AirbyteClient;

beforeAll(async () => {
destinationId = process.env.DESTINATION_ID;
hasuraAdminSecret = process.env.HASURA_GRAPHQL_ADMIN_SECRET;

airbyteClient = new AirbyteClient('http://localhost:8000');
Expand All @@ -29,7 +27,7 @@ describe('integration tests', () => {
'check connection to the Faros destination',
async () => {
expect(
await airbyteClient.checkDestinationConnection(destinationId)
await airbyteClient.checkDestinationConnection('Faros Destination')
).toBe(true);
},
60 * 1000
Expand All @@ -40,7 +38,7 @@ describe('integration tests', () => {
async () => {
const connectionConfiguration: ConnectionConfiguration =
await airbyteClient.getDestinationConnectionConfiguration(
destinationId
'Faros Destination'
);

connectionConfiguration.edition_configs.hasura_admin_secret =
Expand Down

0 comments on commit 1ef3b63

Please sign in to comment.