Use api calls for updateTable test helper

This commit is contained in:
Adria Navarro 2024-01-26 10:57:05 +01:00
parent cb53d31833
commit da9f367962
1 changed files with 7 additions and 14 deletions

View File

@ -592,9 +592,11 @@ class TestConfiguration {
{ skipReassigning } = { skipReassigning: false } { skipReassigning } = { skipReassigning: false }
): Promise<Table> { ): Promise<Table> {
config = config || basicTable() config = config || basicTable()
config.sourceType = config.sourceType || TableSourceType.INTERNAL const response = await this.api.table.save({
config.sourceId = config.sourceId || INTERNAL_TABLE_SOURCE_ID ...config,
const response = await this._req(config, null, controllers.table.save) sourceType: config.sourceType || TableSourceType.INTERNAL,
sourceId: config.sourceId || INTERNAL_TABLE_SOURCE_ID,
})
if (!skipReassigning) { if (!skipReassigning) {
this.table = response this.table = response
} }
@ -618,7 +620,7 @@ class TestConfiguration {
async createExternalTable( async createExternalTable(
config?: TableToBuild, config?: TableToBuild,
options = { skipReassigning: false } options = { skipReassigning: false }
): Promise<Table> { ) {
if (config != null && config._id) { if (config != null && config._id) {
delete config._id delete config._id
} }
@ -627,16 +629,7 @@ class TestConfiguration {
config.sourceId = this.datasource._id config.sourceId = this.datasource._id
config.sourceType = TableSourceType.EXTERNAL config.sourceType = TableSourceType.EXTERNAL
} }
const table = await this.api.table.create({ return this.updateTable(config, options)
...config,
sourceType: config.sourceType || TableSourceType.INTERNAL,
sourceId: config.sourceId || INTERNAL_TABLE_SOURCE_ID,
})
if (!options.skipReassigning) {
this.table = table
}
return table
} }
async getTable(tableId?: string) { async getTable(tableId?: string) {