Fix rest import tests for url and invert dynamic variable invalidation / deletion
This commit is contained in:
parent
5c56abdadf
commit
06114d9481
|
@ -35,7 +35,6 @@ describe("Curl Import", () => {
|
|||
it("returns import info", async () => {
|
||||
await init("get")
|
||||
const info = await curl.getInfo()
|
||||
expect(info.url).toBe("http://example.com")
|
||||
expect(info.name).toBe("example.com")
|
||||
})
|
||||
|
||||
|
@ -67,8 +66,8 @@ describe("Curl Import", () => {
|
|||
}
|
||||
|
||||
it("populates path", async () => {
|
||||
await testPath("get", "")
|
||||
await testPath("path", "paths/abc")
|
||||
await testPath("get", "http://example.com/")
|
||||
await testPath("path", "http://example.com/paths/abc")
|
||||
})
|
||||
|
||||
const testHeaders = async (file, headers) => {
|
||||
|
|
|
@ -41,7 +41,6 @@ describe("OpenAPI2 Import", () => {
|
|||
const testImportInfo = async (file, extension) => {
|
||||
await init(file, extension)
|
||||
const info = await openapi2.getInfo()
|
||||
expect(info.url).toBe("https://petstore.swagger.io/v2")
|
||||
expect(info.name).toBe("Swagger Petstore")
|
||||
}
|
||||
|
||||
|
@ -92,12 +91,12 @@ describe("OpenAPI2 Import", () => {
|
|||
|
||||
it("populates path", async () => {
|
||||
const assertions = {
|
||||
"createEntity" : "entities",
|
||||
"getEntities" : "entities",
|
||||
"getEntity" : "entities/{{entityId}}",
|
||||
"updateEntity" : "entities/{{entityId}}",
|
||||
"patchEntity" : "entities/{{entityId}}",
|
||||
"deleteEntity" : "entities/{{entityId}}"
|
||||
"createEntity" : "http://example.com/entities",
|
||||
"getEntities" : "http://example.com/entities",
|
||||
"getEntity" : "http://example.com/entities/{{entityId}}",
|
||||
"updateEntity" : "http://example.com/entities/{{entityId}}",
|
||||
"patchEntity" : "http://example.com/entities/{{entityId}}",
|
||||
"deleteEntity" : "http://example.com/entities/{{entityId}}"
|
||||
}
|
||||
await runTests("crud", testPath, assertions)
|
||||
})
|
||||
|
|
|
@ -51,30 +51,24 @@ describe("Rest Importer", () => {
|
|||
await init(data)
|
||||
const info = await restImporter.getInfo()
|
||||
expect(info.name).toBe(assertions[key].name)
|
||||
expect(info.url).toBe(assertions[key].url)
|
||||
}
|
||||
|
||||
it("gets info", async () => {
|
||||
const assertions = {
|
||||
"oapi2CrudJson" : {
|
||||
name: "CRUD",
|
||||
url: "http://example.com"
|
||||
},
|
||||
"oapi2CrudYaml" : {
|
||||
name: "CRUD",
|
||||
url: "http://example.com"
|
||||
},
|
||||
"oapi2PetstoreJson" : {
|
||||
name: "Swagger Petstore",
|
||||
url: "https://petstore.swagger.io/v2"
|
||||
},
|
||||
"oapi2PetstoreYaml" :{
|
||||
name: "Swagger Petstore",
|
||||
url: "https://petstore.swagger.io/v2"
|
||||
},
|
||||
"curl": {
|
||||
name: "example.com",
|
||||
url: "http://example.com"
|
||||
}
|
||||
}
|
||||
await runTest(testGetInfo, assertions)
|
||||
|
|
|
@ -173,16 +173,16 @@ const removeDynamicVariables = async (db, queryId) => {
|
|||
const dynamicVariables = datasource.config.dynamicVariables
|
||||
|
||||
if (dynamicVariables) {
|
||||
// delete dynamic variables from the datasource
|
||||
const newVariables = dynamicVariables.filter(dv => dv.queryId !== queryId)
|
||||
datasource.config.dynamicVariables = newVariables
|
||||
await db.put(datasource)
|
||||
|
||||
// invalidate the deleted variables
|
||||
const variablesToDelete = dynamicVariables.filter(
|
||||
dv => dv.queryId === queryId
|
||||
)
|
||||
await invalidateDynamicVariables(variablesToDelete)
|
||||
|
||||
// delete dynamic variables from the datasource
|
||||
const newVariables = dynamicVariables.filter(dv => dv.queryId !== queryId)
|
||||
datasource.config.dynamicVariables = newVariables
|
||||
await db.put(datasource)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue