mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten google music assertions
This commit is contained in:
@@ -20,6 +20,32 @@ import * as providerAuthRuntime from "openclaw/plugin-sdk/provider-auth-runtime"
|
||||
import { expectExplicitMusicGenerationCapabilities } from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import { buildGoogleMusicGenerationProvider } from "./music-generation-provider.js";
|
||||
|
||||
type GoogleGenAIConfig = {
|
||||
apiKey?: string;
|
||||
httpOptions?: {
|
||||
baseUrl?: string;
|
||||
};
|
||||
};
|
||||
|
||||
type GenerateContentRequest = {
|
||||
model?: string;
|
||||
config?: unknown;
|
||||
};
|
||||
|
||||
function lastGoogleGenAIConfig(): GoogleGenAIConfig {
|
||||
const calls = createGoogleGenAIMock.mock.calls as unknown[][];
|
||||
const config = calls.at(-1)?.[0];
|
||||
expect(config).toBeDefined();
|
||||
return config as GoogleGenAIConfig;
|
||||
}
|
||||
|
||||
function firstGenerateContentRequest(): GenerateContentRequest {
|
||||
const calls = generateContentMock.mock.calls as unknown[][];
|
||||
const request = calls[0]?.[0];
|
||||
expect(request).toBeDefined();
|
||||
return request as GenerateContentRequest;
|
||||
}
|
||||
|
||||
describe("google music generation provider", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -69,22 +95,15 @@ describe("google music generation provider", () => {
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(generateContentMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
model: "lyria-3-clip-preview",
|
||||
config: {
|
||||
responseModalities: ["AUDIO", "TEXT"],
|
||||
},
|
||||
}),
|
||||
);
|
||||
const generateRequest = firstGenerateContentRequest();
|
||||
expect(generateRequest.model).toBe("lyria-3-clip-preview");
|
||||
expect(generateRequest.config).toEqual({
|
||||
responseModalities: ["AUDIO", "TEXT"],
|
||||
});
|
||||
expect(result.tracks).toHaveLength(1);
|
||||
expect(result.tracks[0]?.mimeType).toBe("audio/mpeg");
|
||||
expect(result.lyrics).toEqual(["wake the city up"]);
|
||||
expect(createGoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
apiKey: "google-key",
|
||||
}),
|
||||
);
|
||||
expect(lastGoogleGenAIConfig().apiKey).toBe("google-key");
|
||||
});
|
||||
|
||||
it("strips /v1beta suffix from configured baseUrl before passing to GoogleGenAI SDK", async () => {
|
||||
@@ -125,12 +144,8 @@ describe("google music generation provider", () => {
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(createGoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
httpOptions: expect.objectContaining({
|
||||
baseUrl: "https://generativelanguage.googleapis.com",
|
||||
}),
|
||||
}),
|
||||
expect(lastGoogleGenAIConfig().httpOptions?.baseUrl).toBe(
|
||||
"https://generativelanguage.googleapis.com",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -165,12 +180,8 @@ describe("google music generation provider", () => {
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(createGoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
httpOptions: expect.objectContaining({
|
||||
baseUrl: "https://proxy.example.com/v1beta/route",
|
||||
}),
|
||||
}),
|
||||
expect(lastGoogleGenAIConfig().httpOptions?.baseUrl).toBe(
|
||||
"https://proxy.example.com/v1beta/route",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -207,12 +218,8 @@ describe("google music generation provider", () => {
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(createGoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
httpOptions: expect.objectContaining({
|
||||
baseUrl: "https://generativelanguage.googleapis.com",
|
||||
}),
|
||||
}),
|
||||
expect(lastGoogleGenAIConfig().httpOptions?.baseUrl).toBe(
|
||||
"https://generativelanguage.googleapis.com",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -243,13 +250,7 @@ describe("google music generation provider", () => {
|
||||
instrumental: true,
|
||||
});
|
||||
|
||||
expect(createGoogleGenAIMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
httpOptions: expect.not.objectContaining({
|
||||
baseUrl: expect.anything(),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(lastGoogleGenAIConfig().httpOptions?.baseUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects unsupported wav output on clip model", async () => {
|
||||
|
||||
Reference in New Issue
Block a user