-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
545 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import fs from 'fs-extra'; | ||
import {isEqual} from 'lodash'; | ||
import path from 'path'; | ||
|
||
import {HasuraClient} from './hasura-client'; | ||
import {TestDefinition} from './types'; | ||
|
||
let hasuraAdminSecret: string; | ||
let hasuraClient: HasuraClient; | ||
|
||
beforeAll(async () => { | ||
hasuraAdminSecret = process.env.HASURA_GRAPHQL_ADMIN_SECRET; | ||
|
||
hasuraClient = new HasuraClient('http://localhost:8080', hasuraAdminSecret); | ||
await hasuraClient.waitUntilHealthy(); | ||
}, 60 * 1000); | ||
|
||
describe('hasura endpoint tests', () => { | ||
const RESOURCES_DIR = path.join(__dirname, '..', 'resources'); | ||
|
||
test('check cicd_organization Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_organization.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_organization_from_run Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_organization_from_run.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_artifact Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_artifact.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_artifact_commit_association Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_artifact_commit_association.json').then( | ||
(test) => checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_artifact_deployment Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_artifact_deployment.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_artifact_with_build Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_artifact_with_build.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_build Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_build.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_build_with_start_end Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_build_with_start_end.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_pipeline Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_pipeline.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check cicd_repository Hasura endpoint', async () => { | ||
await loadTestDefinition('cicd_repository.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
test('check compute_application Hasura endpoint', async () => { | ||
await loadTestDefinition('compute_application.json').then((test) => | ||
checkHasuraEndpoint(test) | ||
); | ||
}); | ||
|
||
async function loadTestDefinition( | ||
testDefinitionFileName: string | ||
): Promise<TestDefinition> { | ||
const directory = path.join(RESOURCES_DIR, 'hasura', 'test_definitions'); | ||
|
||
return JSON.parse( | ||
await fs.readFile(path.join(directory, testDefinitionFileName), 'utf8') | ||
); | ||
} | ||
|
||
async function checkHasuraEndpoint(test: TestDefinition) { | ||
const directory = path.join(RESOURCES_DIR, 'hasura', 'test_data'); | ||
|
||
const input = await fs.readFile(path.join(directory, test.input), 'utf8'); | ||
const expectedOutput = await fs.readFile( | ||
path.join(directory, test.output), | ||
'utf8' | ||
); | ||
const query = await fs.readFile(path.join(directory, test.query), 'utf8'); | ||
|
||
await hasuraClient.hitEndpoint(test.endpoint, input); | ||
const output = await hasuraClient.makeQuery(query); | ||
|
||
expect(isEqual(output, JSON.parse(expectedOutput))).toBe(true); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query MyQuery { | ||
cicd_Artifact(where: {origin: {_eq: "cicd_artifact_test"}}) { | ||
build | ||
id | ||
name | ||
origin | ||
repository | ||
tags | ||
type | ||
uid | ||
url | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
init/test/resources/hasura/test_data/cicd_artifact_commit_association.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
query MyQuery { | ||
cicd_ArtifactCommitAssociation(where: {origin: {_eq: "cicd_artifact_commit_association_test"}}) { | ||
artifact | ||
commit | ||
id | ||
origin | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
init/test/resources/hasura/test_data/cicd_artifact_commit_association_in.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"data_artifact_repository": "artifact_repository1", | ||
"data_commit_organization": "commit_organization1", | ||
"data_artifact_id": "artifact_id1", | ||
"data_commit_repository": "commit_repository1", | ||
"data_artifact_organization": "artifact_organization1", | ||
"data_commit_sha": "commit_sha1", | ||
"data_commit_source": "commit_source1", | ||
"data_artifact_source": "artifact_source1", | ||
"data_origin": "cicd_artifact_commit_association_test" | ||
} |
12 changes: 12 additions & 0 deletions
12
init/test/resources/hasura/test_data/cicd_artifact_commit_association_out.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"data": { | ||
"cicd_ArtifactCommitAssociation": [ | ||
{ | ||
"artifact": "artifact_source1|artifact_organization1|artifact_repository1|artifact_id1", | ||
"commit": "commit_source1|commit_organization1|commit_repository1|commit_sha1", | ||
"id": "artifact_source1|artifact_organization1|artifact_repository1|artifact_id1|commit_source1|commit_organization1|commit_repository1|commit_sha1", | ||
"origin": "cicd_artifact_commit_association_test" | ||
} | ||
] | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
init/test/resources/hasura/test_data/cicd_artifact_deployment.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
query MyQuery { | ||
cicd_ArtifactDeployment(where: {origin: {_eq: "cicd_artifact_deployment_test"}}) { | ||
artifact | ||
deployment | ||
id | ||
origin | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
init/test/resources/hasura/test_data/cicd_artifact_deployment_in.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"data_artifact_id": "artifact_id1", | ||
"data_artifact_organization": "artifact_organization1", | ||
"data_artifact_repository": "artifact_repository1", | ||
"data_artifact_source": "artifact_source1", | ||
"data_deploy_id": "deploy_id1", | ||
"data_deploy_source": "deploy_source1", | ||
"data_origin": "cicd_artifact_deployment_test" | ||
} |
12 changes: 12 additions & 0 deletions
12
init/test/resources/hasura/test_data/cicd_artifact_deployment_out.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"data": { | ||
"cicd_ArtifactDeployment": [ | ||
{ | ||
"artifact": "artifact_source1|artifact_organization1|artifact_repository1|artifact_id1", | ||
"deployment": "deploy_source1|deploy_id1", | ||
"id": "artifact_source1|artifact_organization1|artifact_repository1|artifact_id1|deploy_source1|deploy_id1", | ||
"origin": "cicd_artifact_deployment_test" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"data_origin": "cicd_artifact_test", | ||
"data_artifact_repository": "repository1", | ||
"data_artifact_id": "artifact1", | ||
"data_artifact_organization": "organization1", | ||
"data_artifact_source": "source1" | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
init/test/resources/hasura/test_data/cicd_artifact_out.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"data": { | ||
"cicd_Artifact": [ | ||
{ | ||
"build": null, | ||
"id": "source1|organization1|repository1|artifact1", | ||
"name": null, | ||
"origin": "cicd_artifact_test", | ||
"repository": "source1|organization1|repository1", | ||
"tags": null, | ||
"type": null, | ||
"uid": "artifact1", | ||
"url": null | ||
} | ||
] | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
init/test/resources/hasura/test_data/cicd_artifact_with_build.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query MyQuery { | ||
cicd_Artifact(where: {origin: {_eq: "cicd_artifact_with_build_test"}}) { | ||
build | ||
id | ||
name | ||
origin | ||
repository | ||
tags | ||
type | ||
uid | ||
url | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
init/test/resources/hasura/test_data/cicd_artifact_with_build_in.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"data_artifact_repository": "artifact_repository1", | ||
"data_run_source": "run_source1", | ||
"data_run_pipeline": "run_pipeline1", | ||
"data_artifact_id": "artifact_id2", | ||
"data_run_organization": "run_organization1", | ||
"data_artifact_organization": "artifact_organization1", | ||
"data_run_id": "run_id1", | ||
"data_artifact_source": "artifact_source1", | ||
"data_origin": "cicd_artifact_with_build_test" | ||
} |
17 changes: 17 additions & 0 deletions
17
init/test/resources/hasura/test_data/cicd_artifact_with_build_out.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"data": { | ||
"cicd_Artifact": [ | ||
{ | ||
"build": "run_source1|run_organization1|run_pipeline1|run_id1", | ||
"id": "artifact_source1|artifact_organization1|artifact_repository1|artifact_id2", | ||
"name": null, | ||
"origin": "cicd_artifact_with_build_test", | ||
"repository": "artifact_source1|artifact_organization1|artifact_repository1", | ||
"tags": null, | ||
"type": null, | ||
"uid": "artifact_id2", | ||
"url": null | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
query MyQuery { | ||
cicd_Build(where: {origin: {_eq: "cicd_build_test"}}) { | ||
createdAt | ||
endedAt | ||
id | ||
name | ||
number | ||
origin | ||
pipeline | ||
startedAt | ||
status | ||
statusCategory | ||
statusDetail | ||
uid | ||
url | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"data_run_source": "run_source1", | ||
"data_run_pipeline": "run_pipeline1", | ||
"data_run_organization": "run_organization1", | ||
"run_status": {"category": "A", "detail": "B"}, | ||
"data_run_id": "run_id2", | ||
"data_origin": "cicd_build_test" | ||
} |
Oops, something went wrong.