Skip to content

Commit

Permalink
Proper name for GetCollection.
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet committed Jul 15, 2024
1 parent c4008ef commit 979bd91
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion ChromaDB.Client.Tests/ChromaDBCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ namespace ChromaDB.Client.Tests;
[TestFixture]
public class ChromaDBCollectionTests : ChromaDBTestsBase
{
[Test]
public async Task GetCollectionSimple()
{
var name = $"collection{Random.Shared.Next()}";

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
await client.CreateCollection(new DBCreateCollectionRequest()
{
Name = name,
});
var result = await client.GetCollection(name);
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Assert.That(result.Data.Name, Is.EqualTo(name));
}

[Test]
public async Task ListCollectionsSimple()
{
Expand Down Expand Up @@ -127,4 +144,4 @@ public async Task GetOrCreateCollectionDoesExist()
Assert.That(result2.Data.Name, Is.EqualTo(name));
Assert.That(result1.Data.Id, Is.EqualTo(result2.Data.Id));
}
}
}
2 changes: 1 addition & 1 deletion ChromaDB.Client/Services/Implementations/ChromaDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<BaseResponse<List<Collection>>> ListCollections(string? tenant
return await _httpClient.Get<Collection, List<Collection>>(requestParams);
}

public async Task<BaseResponse<Collection>> GetCollectionByName(string name, string? tenant = null, string? database = null)
public async Task<BaseResponse<Collection>> GetCollection(string name, string? tenant = null, string? database = null)
{
tenant = tenant is not null and not [] ? tenant : _currentTenant.Name;
database = database is not null and not [] ? database : _currentDatabase.Name;
Expand Down
2 changes: 1 addition & 1 deletion ChromaDB.Client/Services/Interfaces/IChromaDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ChromaDB.Client.Services.Interfaces;

public interface IChromaDBClient
{
Task<BaseResponse<Collection>> GetCollectionByName(string name, string? tenant = null, string? database = null);
Task<BaseResponse<Collection>> GetCollection(string name, string? tenant = null, string? database = null);
Task<BaseResponse<List<Collection>>> ListCollections(string? tenant = null, string? database = null);
Task<BaseResponse<Heartbeat>> Heartbeat();
Task<BaseResponse<Collection>> CreateCollection(DBCreateCollectionRequest request, string? tenant = null, string? database = null);
Expand Down
2 changes: 1 addition & 1 deletion Samples/ChromaDB.Client.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

BaseResponse<List<Collection>> collections = await client.ListCollections(database: "test", tenant: "nedeljko");

BaseResponse<Collection> collection1 = await client.GetCollectionByName("string5", database: "test", tenant: "nedeljko");
BaseResponse<Collection> collection1 = await client.GetCollection("string5", database: "test", tenant: "nedeljko");

IChromaCollectionClient string5Client = new ChromaCollectionFactory(configOptions).Create(collection1.Data!, httpClient);

Expand Down

0 comments on commit 979bd91

Please sign in to comment.