Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Natoandro committed Jul 3, 2024
1 parent 109f68f commit 4827c6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions typegate/tests/e2e/cli/dev_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert, assertEquals, assertRejects } from "std/assert/mod.ts";
import { randomSchema, reset } from "test-utils/database.ts";
import { TestModule } from "test-utils/test_module.ts";
import { $ } from "dax";
import { killProcess, LineReader, LineWriter } from "../../utils/process.ts";
import { killProcess, Lines, LineWriter } from "../../utils/process.ts";
import { workspaceDir } from "../../utils/dir.ts";

const m = new TestModule(import.meta);
Expand Down Expand Up @@ -64,7 +64,7 @@ Meta.test(
stdin: "piped",
}).spawn();

const stderr = new LineReader(metadev.stderr);
const stderr = new Lines(metadev.stderr);
const stdin = new LineWriter(metadev.stdin);

await stderr.readWhile((line) => {
Expand Down Expand Up @@ -183,7 +183,7 @@ Meta.test(
stdin: "piped",
}).spawn();

const stderr = new LineReader(metadev.stderr);
const stderr = new Lines(metadev.stderr);
const stdin = new LineWriter(metadev.stdin);

await stderr.readWhile((line) => {
Expand Down Expand Up @@ -259,7 +259,7 @@ Meta.test("meta dev with typegate", async (t) => {
args: ["dev"],
stderr: "piped",
}).spawn();
const stderr = new LineReader(metadev.stderr);
const stderr = new Lines(metadev.stderr);

const deployed: [string, string][] = [];

Expand Down
16 changes: 8 additions & 8 deletions typegate/tests/e2e/upgrade/upgrade_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Untar } from "std/archive/untar.ts";
import { readerFromIterable } from "std/streams/mod.ts";
import { copy } from "std/io/copy.ts";
import { encodeBase64 } from "std/encoding/base64.ts";
import { ProcessOutputLines } from "test-utils/process.ts";
import { Lines } from "test-utils/process.ts";
import { newTempDir } from "test-utils/dir.ts";
import { transformSyncConfig } from "@typegate/config.ts";
import { clearSyncData, setupSync } from "test-utils/hooks.ts";
Expand Down Expand Up @@ -198,12 +198,12 @@ Meta.test(

const typegraphs: string[] = [];

const stdout = new ProcessOutputLines(proc.stdout);
await stdout.fetchUntil((line) => {
const stdout = new Lines(proc.stdout);
await stdout.readWhile((line) => {
// console.log("typegate>", line);
return !line.includes("typegate ready on 7899");
});
stdout.fetchUntil((line) => {
stdout.readWhile((line) => {
const match = line.match(/Initializing engine '(.+)'/);
if (match) {
typegraphs.push(match[1]);
Expand Down Expand Up @@ -246,15 +246,15 @@ Meta.test(
stderr: "piped",
}).spawn();

const stdout = new ProcessOutputLines(proc.stdout);
const stderr = new ProcessOutputLines(proc.stderr);
const stdout = new Lines(proc.stdout);
const stderr = new Lines(proc.stderr);

stderr.fetchUntil((line) => {
stderr.readWhile((line) => {
console.log("typegate[E]>", line);
return true;
});

await stdout.fetchUntil((line) => {
await stdout.readWhile((line) => {
console.log("typegate>", line);
const match = $.stripAnsi(line).match(/reloaded addition: (.+)/);
if (match) {
Expand Down
2 changes: 1 addition & 1 deletion typegate/tests/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Consumer = {
(line: string): boolean | Promise<boolean>; // return false to stop
};

export class LineReader {
export class Lines {
#stream: ReadableStream<string>;
#reader: ReadableStreamDefaultReader<string>;

Expand Down

0 comments on commit 4827c6b

Please sign in to comment.