-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
68 additions
and
68 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
21 changes: 10 additions & 11 deletions
21
apps/velo-external-db/test/drivers/index_api_rest_test_support.ts
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,25 +1,24 @@ | ||
import { authOwner } from "@wix-velo/external-db-testkit" | ||
import { streamToArray } from "@wix-velo/test-commons" | ||
import waitUntil from "async-wait-until" | ||
import { CreateIndexRequest, Index, ListIndexesRequest } from "libs/velo-external-db-core/src/spi-model/indexing" | ||
import { streamToArray } from '@wix-velo/test-commons' | ||
import waitUntil from 'async-wait-until' | ||
import { indexSpi } from '@wix-velo/velo-external-db-core' | ||
|
||
const axios = require('axios').create({ | ||
baseURL: 'http://localhost:8080' | ||
}) | ||
|
||
export const givenIndexes = async (collectionName: string, indexes: Index[], auth: any) => { | ||
export const givenIndexes = async(collectionName: string, indexes: indexSpi.Index[], auth: any) => { | ||
for (const index of indexes) { | ||
await axios.post('/indexes/create', { dataCollectionId: collectionName, index } as CreateIndexRequest, auth) | ||
await axios.post('/indexes/create', { dataCollectionId: collectionName, index } as indexSpi.CreateIndexRequest, auth) | ||
} | ||
await Promise.all(indexes.map(index => indexCreated(collectionName, index.name, auth))) | ||
} | ||
|
||
const indexCreated = async (collectionName: string, indexName: string, auth: any) => { | ||
await waitUntil(async () => { | ||
const indexes = await retrieveIndexesFor(collectionName) as Index[] | ||
const indexCreated = async(collectionName: string, indexName: string, auth: any) => { | ||
await waitUntil(async() => { | ||
const indexes = await retrieveIndexesFor(collectionName, auth) as indexSpi.Index[] | ||
return indexes.some(index => index.name === indexName) | ||
}) | ||
} | ||
|
||
export const retrieveIndexesFor = async (collectionName: string) => axios.post('/indexes/list', { dataCollectionId: collectionName }, {responseType: 'stream', ...authOwner}) | ||
.then(response => streamToArray(response.data)) | ||
export const retrieveIndexesFor = async(collectionName: string, auth: any) => axios.post('/indexes/list', { dataCollectionId: collectionName }, { responseType: 'stream', ...auth }) | ||
.then(response => streamToArray(response.data)) |
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 |
---|---|---|
|
@@ -99,4 +99,4 @@ export class IndexDoesNotExist extends BaseHttpError { | |
constructor(message: string) { | ||
super(message, 404) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -42,4 +42,4 @@ export default class IndexService { | |
order: spiIndex.fields[0].order, | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -270,4 +270,4 @@ export enum DomainIndexStatus { | |
ACTIVE = 'ACTIVE', | ||
BUILDING = 'BUILDING', | ||
FAILED = 'FAILED' | ||
} | ||
} |