-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Christoph Kuhnke <github@kuhnke.net>
- Loading branch information
1 parent
0f22753
commit ebeb1ce
Showing
7 changed files
with
121 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ExasolExtension } from "../api"; | ||
import { JavaVirtualSchemaBaseExtension, convertVirtualSchemaBaseExtension, createJsonConnectionDefinition, createVirtualSchemaBuilder } from "../base-vs"; | ||
import { successResult } from "../base/common"; | ||
import { testJavaVirtualSchemaBaseExtension } from "./vsTestBase"; | ||
|
||
|
||
|
||
function emptyBaseVsExtension(): JavaVirtualSchemaBaseExtension { | ||
const adapterName = "vs-adapter-script-name" | ||
return { | ||
name: "testing-base-extension", | ||
version: "v0", | ||
category: "test-category", | ||
description: "Testing base extension", | ||
files: [{ | ||
name: "test-ext.jar", | ||
size: 12345 | ||
}], | ||
scripts: [{ name: adapterName, type: "SCALAR", parameters: "...", emitParameters: "...", scriptClass: "com.exasol.TestingAdapter" }], | ||
scriptVersionExtractor: () => successResult("dummy version"), | ||
virtualSchemaAdapterScript: adapterName, | ||
builder: createVirtualSchemaBuilder({ | ||
connectionNameProperty: "CONNECTION_NAME", | ||
virtualSchemaParameters: [ | ||
{ id: "VS_Required", name: "n1", type: "string", required: true }, | ||
{ id: "VS_Optional", name: "n2", type: "string", required: false }], | ||
connectionDefinition: createJsonConnectionDefinition([ | ||
{ id: "connRequired", name: "n1", type: "string", required: true }, | ||
{ id: "connOptional", name: "n2", type: "string", required: false }]) | ||
}) | ||
} | ||
} | ||
|
||
function createExtension(): ExasolExtension { | ||
return convertVirtualSchemaBaseExtension(emptyBaseVsExtension()); | ||
} | ||
|
||
testJavaVirtualSchemaBaseExtension(createExtension); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { describe, expect, it } from '@jest/globals'; | ||
import { ExasolExtension } from '../api'; | ||
import { createMockContext } from '../base/test-utils'; | ||
|
||
/** | ||
* This function runs shared tests for a virtual schema extension. | ||
* | ||
* Call this function in your test file to test your virtual schema extension. | ||
* It will assert basic properties of your extension, e.g. having an ID, names | ||
* of parameters satisfy conform to the naming conventions, etc. See the | ||
* descriptions of the contained test cases for details. | ||
* @param extensionProvider factory for the extension to test | ||
*/ | ||
export function testJavaVirtualSchemaBaseExtension(extensionProvider: () => ExasolExtension) { | ||
const extension = extensionProvider(); | ||
describe(`extension ${extension.name} versions`, () => { | ||
it("has at least one version", () => { | ||
expect(extension.installableVersions.length).toBeGreaterThan(0); | ||
}); | ||
}); | ||
describe(`extension ${extension.name} parameters`, () => { | ||
const parameters = extension.getInstanceParameters(createMockContext(), extension.installableVersions[0].name) | ||
it("has at least one parameter", () => { | ||
expect(parameters.length).toBeGreaterThan(0); | ||
}); | ||
it("contains virtual schema name", () => { | ||
expect(parameters.some(p => p.id === "baseVirtualSchemaName")).toBe(true); | ||
}); | ||
it("have a unique ID", () => { | ||
const ids = parameters.map(p => p.id); | ||
expect(new Set(ids).size).toBe(ids.length); | ||
}); | ||
for (const param of parameters) { | ||
it(`parameter '${param.id}' conforms to naming conventions`, () => { | ||
expect(param.id).not.toContain("."); | ||
}); | ||
} | ||
}); | ||
} |
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