Skip to content

Commit

Permalink
chore: add test suite for user specific root
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed Sep 21, 2022
1 parent 8987d63 commit 7e911cd
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test-fixtures/suite4/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"smithyLsp.rootPath": "${workspaceRoot}/smithy"
}
59 changes: 59 additions & 0 deletions test-fixtures/suite4/smithy/main.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$version: "2.0"

namespace example.weather

use aws.api#dataPlane
use smithy.waiters#waitable

/// Provides weather forecasts.
service Weather {
version: "2006-03-01"
operations: [GetCurrentTime, GetWeatherReport]
}

@readonly
@dataPlane
operation GetCurrentTime {
input := {}
output := {
@required
time: Timestamp
}
}

@waitable(
ReportGenerated: {
documentation: "Wait until the weather report is generated"
acceptors: [
{
state: "success"
matcher: {
success: true
}
}
{
state: "retry"
matcher: {
errorType: "NotFound"
}
}
]
}
)
operation GetWeatherReport {
input := {
@required
cityId: String
}
output := {
@required
temperature: String
}
errors: [NotFound]
}

@error("client")
structure NotFound {
@required
message: String
}
6 changes: 6 additions & 0 deletions test-fixtures/suite4/smithy/smithy-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"maven": {
"dependencies": ["software.amazon.smithy:smithy-aws-traits:1.25.0", "software.amazon.smithy:smithy-waiters:1.25.0"],
"repositories": [{ "url": "https://repo1.maven.org/maven2/" }]
}
}
7 changes: 7 additions & 0 deletions tests/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ async function go() {
launchArgs: [resolve(__dirname, "../../test-fixtures/suite3")],
});

// Suite 4 - User-specific root
await runTests({
extensionDevelopmentPath,
extensionTestsPath: resolve(__dirname, "./suite4"),
launchArgs: [resolve(__dirname, "../../test-fixtures/suite4")],
});

// Confirm that webpacked and vsce packaged extension can be installed.
const vscodeExecutablePath = await downloadAndUnzipVSCode();
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
Expand Down
20 changes: 20 additions & 0 deletions tests/suite4/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as assert from "assert";
import * as vscode from "vscode";
import { getDocUri, getLangServerLogs, waitForServerStartup } from "../helper";

suite("User-specific root", () => {
test("Should download jars even when not in workspace root", async () => {
const smithyMainUri = getDocUri("suite4/smithy/main.smithy");
const doc = await vscode.workspace.openTextDocument(smithyMainUri);
await vscode.window.showTextDocument(doc);
await waitForServerStartup();
const diagnostics = vscode.languages.getDiagnostics(smithyMainUri);
const logText = await getLangServerLogs("suite4/smithy");

assert.match(logText, /Downloaded external jars.*smithy-aws-traits-1\.25\.0\.jar/);
assert.match(logText, /Downloaded external jars.*smithy-waiters-1\.25\.0\.jar/);
assert.match(logText, /Discovered smithy files.*\/main.smithy]/);
assert.doesNotMatch(logText, /Unable to resolve trait/);
assert.equal(diagnostics.length, 0);
}).timeout(10000);
});
5 changes: 5 additions & 0 deletions tests/suite4/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runTests } from "../helper";

export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void {
runTests(testsRoot, cb);
}

0 comments on commit 7e911cd

Please sign in to comment.