Skip to content

Commit

Permalink
Fix some integration test mocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Griffin committed Dec 9, 2024
1 parent ba0dc0b commit 2e67b96
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
14 changes: 10 additions & 4 deletions __tests__/integration/client-last-txn-tracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ describe("last_txn_ts tracking in client", () => {
},

close() {},
getURL(): string {
return "http://foo.com/bar";
},
};

const myClient = getClient(
{
query_timeout_ms: 60_000,
},
httpClient
httpClient,
);

const resultOne = await myClient.query(fql`
Expand All @@ -35,7 +38,7 @@ describe("last_txn_ts tracking in client", () => {
fql`
if (Collection.byName('Orders') == null) {
Collection.create({ name: 'Orders' })
}`
}`,
);
expect(resultTwo.txn_ts).not.toBeUndefined();
expect(resultTwo.txn_ts).not.toEqual(resultOne.txn_ts);
Expand Down Expand Up @@ -63,13 +66,16 @@ describe("last_txn_ts tracking in client", () => {
},

close() {},
getURL(): string {
return "http://foo.com/bar";
},
};

const myClient = getClient(
{
query_timeout_ms: 60_000,
},
httpClient
httpClient,
);

const resultOne = await myClient.query(fql`
Expand All @@ -85,7 +91,7 @@ describe("last_txn_ts tracking in client", () => {
if (Collection.byName('Orders') == null) {\
Collection.create({ name: 'Orders' })\
}
`
`,
);
expect(resultTwo.txn_ts).not.toBeUndefined();
expect(resultTwo.txn_ts).not.toEqual(resultOne.txn_ts);
Expand Down
2 changes: 2 additions & 0 deletions __tests__/integration/feed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getDefaultHTTPClientOptions,
getDefaultSecretAndEndpoint,
} from "../client";
import { defaultLogHandler } from "../../src/util/logging";

const defaultHttpClient = getDefaultHTTPClient(getDefaultHTTPClientOptions());
const { secret } = getDefaultSecretAndEndpoint();
Expand All @@ -29,6 +30,7 @@ const defaultFeedConfig: FeedClientConfiguration = {
max_attempts: 3,
max_backoff: 20,
httpClient: defaultHttpClient,
logger: defaultLogHandler(),
client_timeout_buffer_ms: 5000,
query_timeout_ms: 5000,
};
Expand Down
15 changes: 15 additions & 0 deletions __tests__/integration/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ describe("query", () => {
return dummyResponse;
},
close() {},
getURL(): string {
return "http://foo.com/bar";
},
};
const clientConfiguration: Partial<ClientConfiguration> = {
linearized: true,
Expand All @@ -163,6 +166,9 @@ describe("query", () => {
return dummyResponse;
},
close() {},
getURL() {
return "http://foo.com/bar";
},
};

let clientConfiguration: Partial<ClientConfiguration> = {
Expand Down Expand Up @@ -271,6 +277,9 @@ describe("query", () => {
);
},
close() {},
getURL() {
return "http://foo.com/bar";
},
};
badClient = getClient({}, httpClient);
await badClient.query(fql`"dummy"`);
Expand Down Expand Up @@ -379,6 +388,9 @@ describe("query", () => {
return httpClient.request(badRequest);
},
close() {},
getURL() {
return "http://foo.com/bar";
},
};

const badClient = getClient({}, badHTTPClient);
Expand All @@ -400,6 +412,9 @@ describe("query", () => {
throw new Error("boom!");
},
close() {},
getURL(): string {
return "http://foo.com/bar";
},
};
const badClient = getClient(
{
Expand Down
6 changes: 6 additions & 0 deletions __tests__/integration/set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ describe("SetIterator", () => {
close() {
return;
},
getURL(): string {
return "http://foo.com/bar";
},
};
const testClient = getClient({}, httpClient);

Expand Down Expand Up @@ -248,6 +251,9 @@ describe("SetIterator", () => {
close() {
return;
},
getURL(): string {
return "http://foo.com/bar";
},
};
const testClient = getClient({}, httpClient);

Expand Down
2 changes: 2 additions & 0 deletions __tests__/integration/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getDefaultHTTPClientOptions,
getDefaultSecretAndEndpoint,
} from "../client";
import { defaultLogHandler } from "../../src/util/logging";

const defaultHttpClient = getDefaultHTTPClient(getDefaultHTTPClientOptions());
const { secret } = getDefaultSecretAndEndpoint();
Expand All @@ -31,6 +32,7 @@ const defaultStreamConfig: StreamClientConfiguration = {
long_type: "number",
max_attempts: 3,
max_backoff: 20,
logger: defaultLogHandler(),
httpStreamClient: defaultHttpClient,
};

Expand Down

0 comments on commit 2e67b96

Please sign in to comment.