Skip to content

Commit

Permalink
test: added more error output for diff test for more error output dur…
Browse files Browse the repository at this point in the history
…ing the pipeline
  • Loading branch information
rH4rtinger committed Sep 19, 2024
1 parent efaefcf commit 5b64f35
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/test/e2e/webview/WebviewTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ export class WebviewTestUtils {
await databaseName.sendKeys(config.databaseName, Key.TAB);

const button = await webView.findWebElement(By.id(config.buttonToClick));

await button.click();
try {
await button.click();
} catch (error) {
await VSBrowser.instance.takeScreenshot(`${randomUUID()}-click-${config.buttonToClick}-${config.databaseType}`);
throw error;
}
});

if (config.buttonToClick === "saveButton") {
Expand Down
30 changes: 19 additions & 11 deletions src/test/suite/DockerTestUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { exec } from "child_process";
import { isWindows } from "../../utilities/osUtilities";
import mariadb from "mariadb";
import { VSBrowser } from "vscode-extension-tester";
import { randomUUID } from "crypto";

/**
* Creates and manages a maria docker container for tests.
Expand Down Expand Up @@ -117,13 +119,9 @@ export class DockerTestUtils {
* Checks the status of the specified container and the availability of the database within it.
*
* @param containerName - The name of the container to check.
* @param dbExecutable - The executable for the database client.
* @returns A Promise that resolves when the container status and database availability are checked.
*/
static async checkContainerStatus(
containerName: string = "mariadb",
dbExecutable: string = "mysql-client"
): Promise<void> {
static async checkContainerStatus(containerName: string = "mariadb"): Promise<void> {
const fullContainerName = this.containerNamePrefix + containerName;

// check if container is running
Expand All @@ -134,7 +132,7 @@ export class DockerTestUtils {
case "mariadb":
// install mysql to the container
await this.repeatCommand(
`${this.docker} exec ${fullContainerName} sh -c "apt-get update && apt-get install -y ${dbExecutable}"`
`${this.docker} exec ${fullContainerName} sh -c "apt-get update && apt-get install -y mysql-client"`
);

// check if database is available
Expand All @@ -145,12 +143,22 @@ export class DockerTestUtils {

// check if database is available
case "postgres":
await this.repeatCommand(`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "SELECT 1;"`);
try {
await this.repeatCommand(`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "SELECT 1;"`);
} catch (error) {
await VSBrowser.instance.takeScreenshot(`${randomUUID()}-status-check`);
throw error;
}

//
await this.executeCommand(
`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "CREATE SCHEMA ${this.dbName};"`
);
// create the needed schema
try {
await this.repeatCommand(
`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "CREATE SCHEMA ${this.dbName};"`
);
} catch (error) {
await VSBrowser.instance.takeScreenshot(`${randomUUID()}-create-schema`);
throw error;
}
break;

default:
Expand Down

0 comments on commit 5b64f35

Please sign in to comment.