Skip to content

Commit

Permalink
fix: fix test and add delay between requests
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury committed Feb 5, 2024
1 parent d9dbeef commit b2ce138
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/backend/src/managers/playground.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ beforeEach(() => {
{} as PodmanConnection,
);
originalFetch = globalThis.fetch;
globalThis.fetch = vi.fn().mockResolvedValue({});
globalThis.fetch = vi.fn().mockResolvedValue({
ok: true,
});
});

afterEach(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/managers/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type { PlaygroundState, PlaygroundStatus } from '@shared/src/models/IPlay
import type { ContainerRegistry } from '../registries/ContainerRegistry';
import type { PodmanConnection } from './podmanConnection';
import OpenAI from 'openai';
import { timeout } from '../utils/utils';

const LABEL_MODEL_ID = 'ai-studio-model-id';
const LABEL_MODEL_PORT = 'ai-studio-model-port';
Expand Down Expand Up @@ -216,6 +217,7 @@ export class PlayGroundManager {
try {
const response = await fetch(`http://localhost:${freePort}`);
contacted = response.ok;
await timeout(1000);
} catch (err: unknown) {
/* empty */
}
Expand Down

0 comments on commit b2ce138

Please sign in to comment.