Skip to content

Commit

Permalink
Improve object store test
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Jul 1, 2023
1 parent 1654482 commit 1e3d5fa
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions bin/os_compatibility_test.ts
Expand Up @@ -17,7 +17,6 @@ import { connect, millis, Msg } from "../src/mod.ts";

const nc = await connect({ servers: "demo.nats.io" });
const js = nc.jetstream();
const jsm = await js.jetstreamManager();

const sub = nc.subscribe("tests.object_store.>");

Expand All @@ -39,7 +38,7 @@ const customized = async function (m: Msg): Promise<void> {
const entry = async function (m: Msg): Promise<void> {
const t = m.json<{
bucket: string;
config: { description: string; link: null; name: string };
config: { description: string; name: string };
url: string;
}>();

Expand All @@ -55,22 +54,25 @@ const entry = async function (m: Msg): Promise<void> {
m.respond();
};

const done = async function (_: Msg): Promise<void> {
console.log("object store test done");
};

const opts = [
create,
customized,
entry,
done,
];

let i = 0;
for await (const m of sub) {
const r = m.json<{ bucket: string }>();
// if (r.bucket) {
// try {
// await jsm.streams.delete(`OBJ_${r.bucket as string}`);
// } catch (err) {
// // ignore
// }
// }
console.log(r);
if (m.headers) {
for (const [key, value] of m.headers) {
console.log(`${key}=${value}`);
}
throw new Error(`object store failed`);
}
console.log(m);
await opts[i++](m);
}

0 comments on commit 1e3d5fa

Please sign in to comment.