Skip to content

Commit 5628336

Browse files
committed
Fix tests
1 parent f41833c commit 5628336

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

packages/sst/src/iot.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
22
import { useAWSClient, useAWSCredentials } from "./credentials.js";
33
import { VisibleError } from "./error.js";
4+
import { lazy } from "./util/lazy.js";
5+
import { Logger } from "./logger.js";
46

57
export const useIOTEndpoint = lazy(async () => {
68
const iot = useAWSClient(IoTClient);
@@ -21,11 +23,8 @@ export const useIOTEndpoint = lazy(async () => {
2123
import iot from "aws-iot-device-sdk";
2224
import { EventPayload, Events, EventTypes, useBus } from "./bus.js";
2325
import { useProject } from "./project.js";
24-
import { Logger } from "./logger.js";
25-
import { randomUUID } from "crypto";
2626
import { useBootstrap } from "./bootstrap.js";
2727
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
28-
import { lazy } from "./util/lazy.js";
2928

3029
interface Fragment {
3130
id: string;

packages/sst/src/util/user-configuration.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
// @ts-nocheck
21
import * as os from "os";
32
import * as fs_path from "path";
43
import * as fs from "fs";
54
import { fileURLToPath, pathToFileURL } from "url";
65

6+
type Tag = { Key: string; Value: string };
7+
78
export const PROJECT_CONFIG = "cdk.json";
89
export const USER_DEFAULTS = "~/.cdk.json";
910
const CONTEXT_KEY = "context";
1011

11-
let cdkToolkitPath: string;
12+
let cdkToolkitPath = "";
13+
let cdkToolkitUrl = "";
1214

1315
try {
14-
const cdkToolkitUrl = await import.meta.resolve!("@aws-cdk/toolkit-lib");
16+
cdkToolkitUrl = await import.meta.resolve!("@aws-cdk/toolkit-lib");
1517
cdkToolkitPath = fileURLToPath(cdkToolkitUrl);
1618
} catch (e) {
1719
// Fallback for test environment where import.meta.resolve is not available
1820
const module = await import("module");
1921
const require = (module as any).createRequire(import.meta.url);
2022
cdkToolkitPath = require.resolve("@aws-cdk/toolkit-lib");
23+
cdkToolkitUrl = pathToFileURL(cdkToolkitPath).href;
2124
}
2225

2326
const { ToolkitError } = await import(cdkToolkitUrl);
@@ -109,10 +112,10 @@ export class Configuration {
109112
output: "cdk.out",
110113
});
111114

112-
private readonly commandLineArguments: Settings;
113-
private readonly commandLineContext: Settings;
114-
private _projectConfig?: Settings;
115-
private _projectContext?: Settings;
115+
private readonly commandLineArguments: typeof Settings;
116+
private readonly commandLineContext: typeof Settings;
117+
private _projectConfig?: typeof Settings;
118+
private _projectContext?: typeof Settings;
116119
private loaded = false;
117120

118121
constructor(private readonly props: ConfigurationProps = {}) {
@@ -198,11 +201,11 @@ export class Configuration {
198201
}
199202
}
200203

201-
async function loadAndLog(fileName: string): Promise<Settings> {
204+
async function loadAndLog(fileName: string): Promise<typeof Settings> {
202205
return await settingsFromFile(fileName);
203206
}
204207

205-
async function settingsFromFile(fileName: string): Promise<Settings> {
208+
async function settingsFromFile(fileName: string): Promise<typeof Settings> {
206209
let settings;
207210
const expanded = expandHomeDir(fileName);
208211
if (fs.existsSync(expanded)) {
@@ -224,7 +227,7 @@ async function settingsFromFile(fileName: string): Promise<Settings> {
224227
}
225228

226229
function prohibitContextKeys(
227-
settings: Settings,
230+
settings: typeof Settings,
228231
keys: string[],
229232
fileName: string
230233
) {
@@ -245,7 +248,7 @@ function prohibitContextKeys(
245248
}
246249

247250
function warnAboutContextKey(
248-
settings: Settings,
251+
settings: typeof Settings,
249252
prefix: string,
250253
fileName: string
251254
) {

packages/sst/test/constructs/helper.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { Match, Matcher, MatchResult, Template } from "aws-cdk-lib/assertions";
22
import { Stack } from "aws-cdk-lib";
3-
import { App, AppDeployProps, AppProps } from "../../dist/constructs";
3+
import { App, AppDeployProps } from "../../dist/constructs";
44
import { setProject, useProject } from "../../dist/project.js";
5-
import { useNodeHandler } from "../../dist/runtime/handlers/node.js";
6-
import { usePythonHandler } from "../../dist/runtime/handlers/python.js";
7-
import { useDotnetHandler } from "../../dist/runtime/handlers/dotnet.js";
8-
import { useJavaHandler } from "../../dist/runtime/handlers/java.js";
9-
import { useGoHandler } from "../../dist/runtime/handlers/go.js";
10-
import { useContainerHandler } from "../../dist/runtime/handlers/container.js";
11-
import os from "os";
12-
import path from "path";
13-
import fs from "fs/promises";
14-
import crypto from "crypto";
5+
6+
import * as os from "os";
7+
import * as path from "path";
8+
import * as fs from "fs/promises";
9+
import * as crypto from "crypto";
1510

1611
///////////////////////
1712
// Matcher functions //
@@ -34,6 +29,7 @@ export async function createApp(props?: Partial<AppDeployProps>) {
3429
setProject({
3530
version: "test",
3631
cdkVersion: "test",
32+
constructsVersion: "test",
3733
stacks: async () => {},
3834
metafile: null as any,
3935
config: {

0 commit comments

Comments
 (0)