Open md-abid-hussain opened 1 month ago
The fix is simple
The prettier
issue is caused by a redundant import in src/models/modelsRestApiClient.ts
at line 14. This is also causing 4 test case failures.
The one test case is failing due to logic error in the connect
method, which is inside src/index.ts
const connect = async function (options: ConnectionOptions): Promise<void> {
...
const baseURL =
httpClient.defaults.baseURL || Constants.BASE_CLOUD_API_ENDPOINT;
// Need to authenticate if we're using the Cloud API endpoints.
if (isMindsDbCloudEndpoint(baseURL) || !isLocalEndpoint(baseURL)) {
...
}
};
isMindsDbCloudEndpoint method
function isMindsDbCloudEndpoint(url: string): boolean {
// Cloud endpoints:
// - https://cloud.mindsdb.com
// - https://alpha.mindsdb.com
// - https://beta.mindsdb.com
return url.includes('mindsdb.com');
}
isLocalEndpoint
function isLocalEndpoint(url: string): boolean {
return url.includes('localhost') || url.includes('127.0.0.1');
}
And test case is
test('connect should not authenticate for custom endpoint', async () => {
await MindsDB.connect({
host: 'https://test-url.com',
user: 'test-user',
password: 'test-password',
httpClient: mockedAxios,
});
expect(mockedAxios.post).not.toHaveBeenCalled();
});
https://test-url.com
will give true for
if (isMindsDbCloudEndpoint(baseURL) || !isLocalEndpoint(baseURL))
and hence test case will fail
Prettier issue
and failing test cases