Skip to content

Commit

Permalink
test(annotations): added integration test for annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfmi committed Jun 10, 2024
1 parent 16405b8 commit 9436de5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
67 changes: 67 additions & 0 deletions integration/src/annotations.spec.ts
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);
});
});
});
2 changes: 1 addition & 1 deletion packages/js/src/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HTTPClient from './httpClient.js';
export namespace annotations {

export interface Annotation {
id: number;
id: string;
type: string;
datasets: string[];
title?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/js/src/index.ts
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';

0 comments on commit 9436de5

Please sign in to comment.