Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API surface cleanup #58

Merged
merged 19 commits into from
Oct 3, 2024
Merged
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ root = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.cs]
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
csharp_style_var_elsewhere = true
3 changes: 1 addition & 2 deletions ChromaDB.Client.Extensions/ChromaDBClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ChromaDB.Client.Services.Implementations;
using ChromaDB.Client.Services.Interfaces;
using ChromaDB.Client.Common.Constants;
using Microsoft.Extensions.DependencyInjection;

namespace ChromaDB.Client.Extensions;
Expand Down
3 changes: 1 addition & 2 deletions ChromaDB.Client.Tests/ClientResetTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ChromaDB.Client.Services.Implementations;
using ChromaDB.Client.Tests.TestContainer;
using ChromaDB.Client.Tests.TestContainer;
using NUnit.Framework;

namespace ChromaDB.Client.Tests;
Expand Down
61 changes: 13 additions & 48 deletions ChromaDB.Client.Tests/ClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using ChromaDB.Client.Models.Requests;
using ChromaDB.Client.Services.Implementations;
using NUnit.Framework;
using NUnit.Framework;

namespace ChromaDB.Client.Tests;

Expand Down Expand Up @@ -44,10 +42,7 @@ public async Task GetCollectionSimple()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
});
await client.CreateCollection(name);
var result = await client.GetCollection(name);
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Expand All @@ -61,14 +56,8 @@ public async Task ListCollectionsSimple()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
await client.CreateCollection(new CreateCollectionRequest()
{
Name = names[0],
});
await client.CreateCollection(new CreateCollectionRequest()
{
Name = names[1],
});
await client.CreateCollection(names[0]);
await client.CreateCollection(names[1]);
var result = await client.ListCollections();
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Expand All @@ -84,10 +73,7 @@ public async Task CreateCollectionWithoutMetadata()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
var result = await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
});
var result = await client.CreateCollection(name);
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Assert.That(result.Data.Name, Is.EqualTo(name));
Expand All @@ -105,11 +91,8 @@ public async Task CreateCollectionWithMetadata()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
var result = await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
Metadata = metadata,
});
var result = await client.CreateCollection(name,
metadata: metadata);
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Assert.That(result.Data.Name, Is.EqualTo(name));
Expand All @@ -125,14 +108,8 @@ public async Task CreateCollectionAlreadyExists()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
});
var result = await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
});
await client.CreateCollection(name);
var result = await client.CreateCollection(name);
Assert.That(result.Success, Is.False);
Assert.That(result.ErrorMessage, Is.Not.Null.And.Not.Empty);
}
Expand All @@ -144,10 +121,7 @@ public async Task DeleteCollection()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
await client.CreateCollection(new CreateCollectionRequest()
{
Name = name,
});
await client.CreateCollection(name);
var result = await client.DeleteCollection(name);
Assert.That(result.Success, Is.True);
}
Expand All @@ -171,10 +145,7 @@ public async Task GetOrCreateCollectionDoesNotExist()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
var result = await client.GetOrCreateCollection(new GetOrCreateCollectionRequest()
{
Name = name,
});
var result = await client.GetOrCreateCollection(name);
Assert.That(result.Success, Is.True);
Assert.That(result.Data, Is.Not.Null);
Assert.That(result.Data.Name, Is.EqualTo(name));
Expand All @@ -187,14 +158,8 @@ public async Task GetOrCreateCollectionDoesExist()

using var httpClient = new ChromaDBHttpClient(ConfigurationOptions);
var client = new ChromaDBClient(ConfigurationOptions, httpClient);
var result1 = await client.GetOrCreateCollection(new GetOrCreateCollectionRequest()
{
Name = name,
});
var result2 = await client.GetOrCreateCollection(new GetOrCreateCollectionRequest()
{
Name = name,
});
var result1 = await client.GetOrCreateCollection(name);
var result2 = await client.GetOrCreateCollection(name);
Assert.That(result1.Success, Is.True);
Assert.That(result1.Data, Is.Not.Null);
Assert.That(result1.Data.Name, Is.EqualTo(name));
Expand Down
Loading