-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query: make Public, Private, Archive & Unarchive (#29)
- Loading branch information
Showing
7 changed files
with
103 additions
and
34 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
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
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 |
---|---|---|
@@ -1,23 +1,46 @@ | ||
import { expect } from "chai"; | ||
import { QueryParameter, DuneError, QueryAPI } from "../../src/"; | ||
import { apiKey } from "./util"; | ||
import { QueryParameter, QueryAPI } from "../../src/"; | ||
import { PLUS_KEY, BASIC_KEY, expectAsyncThrow } from "./util"; | ||
|
||
const PREMIUM_PLAN_MESSAGE = | ||
"CRUD queries is an advanced feature included only in our premium subscription plans. Please upgrade your plan to use it."; | ||
|
||
describe("QueryAPI: Premium - CRUD Operations", () => { | ||
let plusClient: QueryAPI; | ||
|
||
beforeEach(() => { | ||
plusClient = new QueryAPI(PLUS_KEY); | ||
}); | ||
|
||
it("create, get & update", async () => { | ||
const client = new QueryAPI(apiKey); | ||
let newQuery = await client.createQuery( | ||
let newQuery = await plusClient.createQuery( | ||
"Name", | ||
"select 1", | ||
[QueryParameter.text("What", "name")], | ||
true, | ||
); | ||
let recoveredQuery = await client.getQuery(newQuery.query_id); | ||
let recoveredQuery = await plusClient.getQuery(newQuery.query_id); | ||
expect(newQuery.query_id).to.be.equal(recoveredQuery.query_id); | ||
let updatedQueryId = await client.updateQuery( | ||
let updatedQueryId = await plusClient.updateQuery( | ||
newQuery.query_id, | ||
"New Name", | ||
"select 10;", | ||
); | ||
expect(updatedQueryId).to.be.equal(recoveredQuery.query_id); | ||
}); | ||
}); | ||
|
||
describe("QueryAPI: Errors", () => { | ||
let basicClient: QueryAPI; | ||
|
||
beforeEach(() => { | ||
basicClient = new QueryAPI(BASIC_KEY); | ||
}); | ||
|
||
it("Basic Plan Failure", async () => { | ||
await expectAsyncThrow( | ||
basicClient.createQuery("Query Name", "select 1"), | ||
PREMIUM_PLAN_MESSAGE, | ||
); | ||
}); | ||
}); |
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