Skip to content

Commit 1ca10e4

Browse files
authored
Fix tests (#533)
--------- Signed-off-by: Nik Nasr <[email protected]>
1 parent 4ae428b commit 1ca10e4

File tree

6 files changed

+40
-171
lines changed

6 files changed

+40
-171
lines changed

package-lock.json

Lines changed: 21 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/restate-sdk-examples/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"tsx": "^4.15.7",
44-
"@restatedev/restate-sdk-testcontainers": "^1.5.4",
45-
"testcontainers": "^10.24.1"
44+
"@restatedev/restate-sdk-testcontainers": "^1.5.4"
4645
},
4746
"engines": {
4847
"node": ">= 18.13"

packages/restate-sdk-examples/test/testcontainers.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
1010
*/
1111

12-
import { RestateTestEnvironment } from "@restatedev/restate-sdk-testcontainers";
12+
import {
13+
RestateContainer,
14+
RestateTestEnvironment,
15+
} from "@restatedev/restate-sdk-testcontainers";
1316
import { counter } from "../src/object.js";
1417
import * as clients from "@restatedev/restate-sdk-clients";
1518
import * as core from "@restatedev/restate-sdk-core";
1619
import { describe, it, beforeAll, afterAll, expect } from "vitest";
17-
import { GenericContainer } from "testcontainers";
1820

1921
describe("ExampleObject", () => {
2022
let restateTestEnvironment: RestateTestEnvironment;
@@ -127,7 +129,7 @@ describe("Custom testcontainer config", () => {
127129
restateTestEnvironment = await RestateTestEnvironment.start(
128130
(restateServer) => restateServer.bind(counter),
129131
() =>
130-
new GenericContainer("restatedev/restate:1.1")
132+
new RestateContainer()
131133
.withEnvironment({ RESTATE_LOG_FORMAT: "json" })
132134
.withLogConsumer((stream) => {
133135
// eslint-disable-next-line no-console

packages/restate-sdk-testcontainers/src/public_api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
1010
*/
1111

12-
export { RestateTestEnvironment } from "./restate_test_environment.js";
12+
export {
13+
RestateTestEnvironment,
14+
RestateContainer,
15+
} from "./restate_test_environment.js";

packages/restate-sdk-testcontainers/src/restate_test_environment.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class RestateTestEnvironment {
147147
public static async start(
148148
mountServicesFn: (server: restate.RestateEndpoint) => void,
149149
restateContainerFactory: () => GenericContainer = () =>
150-
new GenericContainer("docker.io/restatedev/restate:latest")
150+
new RestateContainer()
151151
): Promise<RestateTestEnvironment> {
152152
const startedRestateHttpServer = await prepareRestateEndpoint(
153153
mountServicesFn
@@ -167,6 +167,11 @@ export class RestateTestEnvironment {
167167
export type TypedState = Record<string, any>;
168168
export type UntypedState = { _: never };
169169

170+
export class RestateContainer extends GenericContainer {
171+
constructor(version = "latest") {
172+
super(`docker.io/restatedev/restate:${version}`);
173+
}
174+
}
170175
export class StateProxy<TState extends TypedState> {
171176
constructor(
172177
private adminAPIBaseUrl: string,

packages/restate-sdk/test/service_bind.test.ignore.ts renamed to packages/restate-sdk/test/service_bind.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ const greeterFoo = restate.service({
3030

3131
describe("BindService", () => {
3232
it("should preserve `this`", async () => {
33-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-assignment
34-
const handler = greeterFoo["service"]["greet"];
35-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
36-
expect(await handler({}, "abc")).toEqual("abc");
33+
// @ts-expect-error service does not exist in the returned type
34+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
35+
expect(await greeterFoo.service?.greet({}, "abc")).toEqual("abc");
3736
});
3837
});
3938

0 commit comments

Comments
 (0)