-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(annotations): added integration test for annotations
- Loading branch information
Showing
3 changed files
with
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { describe, expect, it, beforeAll, afterAll } from 'vitest'; | ||
import { datasets, annotations } from '@axiomhq/js'; | ||
|
||
const datasetSuffix = process.env.AXIOM_DATASET_SUFFIX || 'local'; | ||
|
||
describe('AnnotationsService', () => { | ||
const datasetName = `test-axiom-js-datasets-${datasetSuffix}`; | ||
const datasetsClient = new datasets.Service({ token: process.env.AXIOM_TOKEN || '', url: process.env.AXIOM_URL, orgId: process.env.AXIOM_ORG_ID }); | ||
const client = new annotations.Service({ token: process.env.AXIOM_TOKEN || '', url: process.env.AXIOM_URL, orgId: process.env.AXIOM_ORG_ID }); | ||
let id: string = ''; | ||
|
||
beforeAll(async () => { | ||
await datasetsClient.create({ | ||
name: datasetName, | ||
description: 'This is a test dataset for datasets integration tests.', | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
const resp = await datasetsClient.delete(datasetName); | ||
expect(resp.status).toEqual(204); | ||
}); | ||
|
||
describe('create', () => { | ||
it('creates annotations successfully', async () => { | ||
const result = await client.create({ | ||
type: 'test-deployment', | ||
datasets: [datasetName], | ||
title: 'test1', | ||
description: 'This is a test description', | ||
url: 'some-url', | ||
}); | ||
|
||
expect(result).not.toEqual(null); | ||
expect(result.title).toEqual("test1"); | ||
|
||
// set id | ||
id = result.id; | ||
}); | ||
}); | ||
|
||
describe('update', () => { | ||
it('should update the annotation', async () => { | ||
const dataset = await client.update(id, { | ||
description: 'This is a soon to be filled test dataset', | ||
}); | ||
|
||
expect(dataset.description).toEqual('This is a soon to be filled test dataset'); | ||
}); | ||
}); | ||
|
||
describe('get', () => { | ||
it('should get the annotation', async () => { | ||
const annotation = await client.get(id); | ||
|
||
expect(annotation.title).toEqual("test1"); | ||
}); | ||
}); | ||
|
||
describe('list', () => { | ||
it('should list the annotations', async () => { | ||
const annotations = await client.list(); | ||
|
||
expect(annotations.length).toBeGreaterThan(0); | ||
}); | ||
}); | ||
}); |
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,4 +1,5 @@ | ||
export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryLegacyResult, QueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js'; | ||
export { ClientOptions } from './httpClient.js'; | ||
export { datasets } from './datasets.js'; | ||
export { annotations } from './annotations.js'; | ||
export { users } from './users.js'; |