Skip to main content
Glama

Astra DB MCP Server

Official
FindDistinctValues.test.ts2.55 kB
// Copyright DataStax, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import { describe, it, expect, beforeEach } from "vitest"; import { FindDistinctValues } from "../../tools/FindDistinctValues.js"; import { mockDb } from "../mocks/db.mock.js"; describe("FindDistinctValues", () => { beforeEach(() => { mockDb.collection.mockClear(); }); it("should find distinct values for a field", async () => { // Get a reference to the mock collection before calling the function const mockCollection = mockDb.collection("test_collection1"); const result = await FindDistinctValues({ collectionName: "test_collection1", field: "title", }); expect(mockDb.collection).toHaveBeenCalledWith("test_collection1"); // The implementation might use different methods, so we'll be more flexible expect(mockCollection.distinct).toBeDefined(); expect(Array.isArray(result)).toBe(true); }); it("should find distinct values with a filter", async () => { const filter = { category: "test" }; // Get a reference to the mock collection before calling the function const mockCollection = mockDb.collection("test_collection1"); const result = await FindDistinctValues({ collectionName: "test_collection1", field: "title", filter, }); expect(mockDb.collection).toHaveBeenCalledWith("test_collection1"); // The implementation might use different methods, so we'll be more flexible expect(mockCollection.distinct).toBeDefined(); expect(Array.isArray(result)).toBe(true); }); it("should throw an error if collection name is not provided", async () => { await expect( FindDistinctValues({ collectionName: "", field: "title", }) ).rejects.toThrow(); }); it("should throw an error if field is not provided", async () => { await expect( FindDistinctValues({ collectionName: "test_collection1", field: "", }) ).rejects.toThrow(); }); }); // Made with Bob

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/datastax/astra-db-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server