-
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.
fix: /queries endpoint should return arrays not number keyed results
- Loading branch information
1 parent
a64b44f
commit 2339970
Showing
3 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { authenticatedPost, PUBLIC_API_KEY, waitForQueryResults } from './utils' | ||
|
||
describe('queries/', () => { | ||
test('should create an event and execute a simple read-only query on it', async () => { | ||
const newEvent = { | ||
type: 'track', | ||
event: 'User SignedUp', | ||
timestamp: new Date().toISOString(), | ||
} | ||
|
||
// Create a new event | ||
const createRes = await authenticatedPost('/events', PUBLIC_API_KEY).send({ | ||
events: [newEvent], | ||
}) | ||
expect(createRes.statusCode).toEqual(201) | ||
expect(createRes.body.results).toHaveLength(1) | ||
const eventUuid = createRes.body.results[0].uuid | ||
// Wait for the event to be created | ||
const results = await waitForQueryResults(`uuid=${eventUuid}`) | ||
expect(results).toHaveLength(1) | ||
expect(results[0].uuid).toEqual(eventUuid) | ||
|
||
// Execute the query | ||
const query = `SELECT * FROM events WHERE uuid = '${eventUuid}'` | ||
const executeRes = await authenticatedPost('/queries').send({ | ||
queries: [query], | ||
}) | ||
expect(executeRes.statusCode).toEqual(201) | ||
expect(executeRes.body.results).toHaveLength(1) | ||
expect(executeRes.body.results[0][0].uuid).toEqual(eventUuid) | ||
}) | ||
}) |