Skip to content

Commit aa061bd

Browse files
committed
replace hardcoded keys with constants
1 parent df6e41c commit aa061bd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/api/providers/fetchers/__tests__/litellm.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { COMPUTER_USE_MODELS } from "../../../../shared/api"
66
jest.mock("axios")
77
const mockedAxios = axios as jest.Mocked<typeof axios>
88

9+
const DUMMY_INVALID_KEY = "invalid-key-for-testing"
10+
911
describe("getLiteLLMModels", () => {
1012
beforeEach(() => {
1113
jest.clearAllMocks()
@@ -165,7 +167,7 @@ describe("getLiteLLMModels", () => {
165167
mockedAxios.isAxiosError.mockReturnValue(true)
166168
mockedAxios.get.mockRejectedValue(axiosError)
167169

168-
await expect(getLiteLLMModels("invalid-key", "http://localhost:4000")).rejects.toThrow(
170+
await expect(getLiteLLMModels(DUMMY_INVALID_KEY, "http://localhost:4000")).rejects.toThrow(
169171
"Failed to fetch LiteLLM models: 401 Unauthorized. Check base URL and API key.",
170172
)
171173
})

src/api/providers/fetchers/__tests__/modelCache.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const mockGetRequestyModels = getRequestyModels as jest.MockedFunction<typeof ge
3434
const mockGetGlamaModels = getGlamaModels as jest.MockedFunction<typeof getGlamaModels>
3535
const mockGetUnboundModels = getUnboundModels as jest.MockedFunction<typeof getUnboundModels>
3636

37+
const DUMMY_REQUESTY_KEY = "requesty-key-for-testing"
38+
const DUMMY_UNBOUND_KEY = "unbound-key-for-testing"
39+
3740
describe("getModels with new GetModelsOptions", () => {
3841
beforeEach(() => {
3942
jest.clearAllMocks()
@@ -88,9 +91,9 @@ describe("getModels with new GetModelsOptions", () => {
8891
}
8992
mockGetRequestyModels.mockResolvedValue(mockModels)
9093

91-
const result = await getModels({ provider: "requesty", apiKey: "requesty-key" })
94+
const result = await getModels({ provider: "requesty", apiKey: DUMMY_REQUESTY_KEY })
9295

93-
expect(mockGetRequestyModels).toHaveBeenCalledWith("requesty-key")
96+
expect(mockGetRequestyModels).toHaveBeenCalledWith(DUMMY_REQUESTY_KEY)
9497
expect(result).toEqual(mockModels)
9598
})
9699

@@ -122,9 +125,9 @@ describe("getModels with new GetModelsOptions", () => {
122125
}
123126
mockGetUnboundModels.mockResolvedValue(mockModels)
124127

125-
const result = await getModels({ provider: "unbound", apiKey: "unbound-key" })
128+
const result = await getModels({ provider: "unbound", apiKey: DUMMY_UNBOUND_KEY })
126129

127-
expect(mockGetUnboundModels).toHaveBeenCalledWith("unbound-key")
130+
expect(mockGetUnboundModels).toHaveBeenCalledWith(DUMMY_UNBOUND_KEY)
128131
expect(result).toEqual(mockModels)
129132
})
130133

0 commit comments

Comments
 (0)