Skip to content

Commit

Permalink
Include Package Version with User-Agent (#38)
Browse files Browse the repository at this point in the history
Also adjusted some inconsistent tests

* extend sleep time
* skip execute cancel get status
  • Loading branch information
bh2smith authored Mar 25, 2024
1 parent 6e3b5dd commit e8ecebe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/api/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
payloadJSON,
payloadSearchParams,
} from "../types/requestPayload";
import { version } from "../../package.json";

const BASE_URL = "https://api.dune.com/api";

Expand Down Expand Up @@ -88,7 +89,7 @@ export class Router {
method,
headers: {
"x-dune-api-key": this.apiKey,
"User-Agent": `ts-client-sdk (https://www.npmjs.com/package/@duneanalytics/client-sdk)`,
"User-Agent": `client-sdk@${version} (https://www.npmjs.com/package/@duneanalytics/client-sdk)`,
},
// conditionally add the body property
...(method !== RequestMethod.GET && {
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/executionAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("ExecutionAPI: native routes", () => {

// This doesn't work if run too many times at once:
// https://discord.com/channels/757637422384283659/1019910980634939433/1026840715701010473
it("returns expected results on sequence execute-cancel-get_status", async () => {
it.skip("returns expected results on sequence execute-cancel-get_status", async () => {
// Long running query ID.
const queryID = 1229120;
// Execute and check state
Expand Down Expand Up @@ -87,14 +87,13 @@ describe("ExecutionAPI: native routes", () => {
});
});

it("getResults", async () => {
it("gets Results", async () => {
const execution = await client.executeQuery(testQueryId);
await sleep(1);
// expect basic query has completed after 1s
await sleep(5);
// expect basic query has completed after 5s
const status = await client.getExecutionStatus(execution.execution_id);
expect(status.state).to.be.eq(ExecutionState.COMPLETED);

// let resultJSON = await client.getExecutionResults(execution.execution_id);
await expect(() => client.getExecutionResults(execution.execution_id)).to.not.throw();

const resultCSV = await client.getResultCSV(execution.execution_id);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "ES2018",
"module": "CommonJS",
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"outDir": "dist",
Expand Down

0 comments on commit e8ecebe

Please sign in to comment.