Skip to content

Commit

Permalink
rename VoaProvider to DataProvider in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
austin-denoble committed Feb 22, 2024
1 parent 90621fb commit 31d2f68
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/data/__tests__/deleteAll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { setupDeleteSuccess } from './deleteOne.test';

describe('deleteAll', () => {
test('calls the openapi delete endpoint, passing deleteAll with target namespace', async () => {
const { VoaProvider, DPA } = setupDeleteSuccess(undefined);
const { DataProvider, DPA } = setupDeleteSuccess(undefined);

const deleteAllFn = deleteAll(VoaProvider, 'namespace');
const deleteAllFn = deleteAll(DataProvider, 'namespace');
const returned = await deleteAllFn();

expect(returned).toBe(void 0);
Expand Down
8 changes: 4 additions & 4 deletions src/data/__tests__/deleteMany.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { setupDeleteSuccess } from './deleteOne.test';

describe('deleteMany', () => {
test('calls the openapi delete endpoint, passing ids with target namespace', async () => {
const { VoaProvider, DPA } = setupDeleteSuccess(undefined);
const { DataProvider, DPA } = setupDeleteSuccess(undefined);

const deleteManyFn = deleteMany(VoaProvider, 'namespace');
const deleteManyFn = deleteMany(DataProvider, 'namespace');
const returned = await deleteManyFn(['123', '456', '789']);

expect(returned).toBe(void 0);
Expand All @@ -15,9 +15,9 @@ describe('deleteMany', () => {
});

test('calls the openapi delete endpoint, passing filter with target namespace', async () => {
const { DPA, VoaProvider } = setupDeleteSuccess(undefined);
const { DPA, DataProvider } = setupDeleteSuccess(undefined);

const deleteManyFn = deleteMany(VoaProvider, 'namespace');
const deleteManyFn = deleteMany(DataProvider, 'namespace');
const returned = await deleteManyFn({ genre: 'ambient' });

expect(returned).toBe(void 0);
Expand Down
8 changes: 4 additions & 4 deletions src/data/__tests__/deleteOne.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const setupDeleteResponse = (response, isSuccess) => {
isSuccess ? Promise.resolve(response) : Promise.reject(response)
);
const DPA = { _delete: fakeDelete } as DataPlaneApi;
const VoaProvider = { provide: async () => DPA } as DataOperationsProvider;
return { DPA, VoaProvider };
const DataProvider = { provide: async () => DPA } as DataOperationsProvider;
return { DPA, DataProvider };
};
export const setupDeleteSuccess = (response) => {
return setupDeleteResponse(response, true);
Expand All @@ -24,9 +24,9 @@ export const setupDeleteFailure = (response) => {

describe('deleteOne', () => {
test('calls the openapi delete endpoint, passing target namespace and the vector id to delete', async () => {
const { VoaProvider, DPA } = setupDeleteSuccess(undefined);
const { DataProvider, DPA } = setupDeleteSuccess(undefined);

const deleteOneFn = deleteOne(VoaProvider, 'namespace');
const deleteOneFn = deleteOne(DataProvider, 'namespace');
const returned = await deleteOneFn('123');

expect(returned).toBe(void 0);
Expand Down
8 changes: 4 additions & 4 deletions src/data/__tests__/describeIndexStats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const setupResponse = (response, isSuccess) => {
const DPA = {
describeIndexStats: fakeDescribeIndexStats,
} as DataPlaneApi;
const VoaProvider = { provide: async () => DPA } as DataOperationsProvider;
return { DPA, VoaProvider };
const DataProvider = { provide: async () => DPA } as DataOperationsProvider;
return { DPA, DataProvider };
};
const setupSuccess = (response) => {
return setupResponse(response, true);
};

describe('describeIndexStats', () => {
test('calls the openapi describe_index_stats endpoint passing filter if provided', async () => {
const { DPA, VoaProvider } = setupSuccess({
const { DPA, DataProvider } = setupSuccess({
namespaces: {
'': { vectorCount: 50 },
},
Expand All @@ -32,7 +32,7 @@ describe('describeIndexStats', () => {
totalVectorCount: 50,
});

const describeIndexStatsFn = describeIndexStats(VoaProvider);
const describeIndexStatsFn = describeIndexStats(DataProvider);
const returned = await describeIndexStatsFn({
filter: { genre: 'classical' },
});
Expand Down
6 changes: 3 additions & 3 deletions src/data/__tests__/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const setupResponse = (response, isSuccess) => {
isSuccess ? Promise.resolve(response) : Promise.reject(response)
);
const DPA = { fetch: fakeFetch } as DataPlaneApi;
const VoaProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new FetchCommand(VoaProvider, 'namespace');
return { DPA, VoaProvider, cmd };
const DataProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new FetchCommand(DataProvider, 'namespace');
return { DPA, DataProvider, cmd };
};
const setupSuccess = (response) => {
return setupResponse(response, true);
Expand Down
6 changes: 3 additions & 3 deletions src/data/__tests__/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const setupResponse = (response, isSuccess) => {
isSuccess ? Promise.resolve(response) : Promise.reject(response)
);
const DPA = { update: fakeUpdate } as DataPlaneApi;
const VoaProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new UpdateCommand(VoaProvider, 'namespace');
return { fakeUpdate, DPA, VoaProvider, cmd };
const DataProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new UpdateCommand(DataProvider, 'namespace');
return { fakeUpdate, DPA, DataProvider, cmd };
};
const setupSuccess = (response) => {
return setupResponse(response, true);
Expand Down
6 changes: 3 additions & 3 deletions src/data/__tests__/upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const setupResponse = (response, isSuccess) => {
isSuccess ? Promise.resolve(response) : Promise.reject(response)
);
const DPA = { upsert: fakeUpsert } as DataPlaneApi;
const VoaProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new UpsertCommand(VoaProvider, 'namespace');
const DataProvider = { provide: async () => DPA } as DataOperationsProvider;
const cmd = new UpsertCommand(DataProvider, 'namespace');

return { fakeUpsert, DPA, VoaProvider, cmd };
return { fakeUpsert, DPA, DataProvider, cmd };
};
const setupSuccess = (response) => {
return setupResponse(response, true);
Expand Down

0 comments on commit 31d2f68

Please sign in to comment.