-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
850da9c
commit 184c45d
Showing
8 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using ChromaDB.Client.Models.Requests; | ||
using ChromaDB.Client.Services.Implementations; | ||
using NUnit.Framework; | ||
|
||
namespace ChromaDB.Client.Tests; | ||
|
||
[TestFixture] | ||
public class ChromaDBCollectionTests : ChromaDBTestsBase | ||
{ | ||
[Test] | ||
public async Task CreateCollectionWithoutMetadata() | ||
{ | ||
using var httpClient = new ChromaDBHttpClient(ConfigurationOptions); | ||
var client = new ChromaDBClient(ConfigurationOptions, httpClient); | ||
var result = await client.CreateCollection(new DBCreateCollectionRequest() | ||
{ | ||
Name = $"collection{Random.Shared.Next()}", | ||
}); | ||
Assert.That(result.Success, Is.True); | ||
} | ||
|
||
[Test] | ||
public async Task CreateCollectionWithMetadata() | ||
{ | ||
using var httpClient = new ChromaDBHttpClient(ConfigurationOptions); | ||
var client = new ChromaDBClient(ConfigurationOptions, httpClient); | ||
var result = await client.CreateCollection(new DBCreateCollectionRequest() | ||
{ | ||
Name = $"collection{Random.Shared.Next()}", | ||
Metadata = new Dictionary<string, object>() | ||
{ | ||
{ "test", "foo" }, | ||
{ "test2", 10 }, | ||
}, | ||
}); | ||
Assert.That(result.Success, Is.True); | ||
} | ||
|
||
[Test] | ||
public async Task CreateCollectionAlreadyExists() | ||
{ | ||
using var httpClient = new ChromaDBHttpClient(ConfigurationOptions); | ||
var client = new ChromaDBClient(ConfigurationOptions, httpClient); | ||
await client.CreateCollection(new DBCreateCollectionRequest() | ||
{ | ||
Name = $"collection_exists", | ||
}); | ||
var result = await client.CreateCollection(new DBCreateCollectionRequest() | ||
{ | ||
Name = $"collection_exists", | ||
}); | ||
Assert.That(result.Success, Is.False); | ||
Assert.That(result.ReasonPhrase, Is.Not.Null.And.Not.Empty); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ChromaDB.Client/Models/Requests/DBCreateCollectionRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ChromaDB.Client.Models.Requests; | ||
|
||
public class DBCreateCollectionRequest | ||
{ | ||
[JsonPropertyName("name")] | ||
public required string Name { get; init; } | ||
|
||
[JsonPropertyName("metadata")] | ||
public IDictionary<string, object>? Metadata { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters