Skip to content

Commit

Permalink
test: Use localhost for local tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Nov 21, 2024
1 parent ce40e4d commit d187afc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/tests/Ollama.IntegrationTests/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static async Task<Environment> PrepareAsync(EnvironmentType environmentTy
{
Timeout = TimeSpan.FromMinutes(10),
},
baseUri: new Uri("http://10.10.5.85:11434/api"));
baseUri: new Uri("http://127.0.0.1:11434/api")); // baseUri: new Uri("http://10.10.5.85:11434/api")

if (!string.IsNullOrEmpty(model))
{
Expand Down
21 changes: 5 additions & 16 deletions src/tests/Ollama.IntegrationTests/Tests.Embeddings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,16 @@ public partial class Tests
[TestMethod]
public async Task Embeddings()
{
await using var container = await Environment.PrepareAsync(EnvironmentType.Container);

if (container.Type == EnvironmentType.Local)
{
var models = await container.ApiClient.Models.ListRunningModelsAsync();
models.Models.Should().BeNullOrEmpty();
}

await container.ApiClient.Models.PullModelAsync("all-minilm").EnsureSuccessAsync();
#if DEBUG
await using var container = await Environment.PrepareAsync(EnvironmentType.Local, "all-minilm");
#else
await using var container = await Environment.PrepareAsync(EnvironmentType.Container, "all-minilm");
#endif

var embeddingResponse = await container.ApiClient.Embeddings.GenerateEmbeddingAsync(
model:"all-minilm",
prompt: "hello");

embeddingResponse.Embedding.Should().NotBeNullOrEmpty();

if (container.Type == EnvironmentType.Local)
{
var models2 = await container.ApiClient.Models.ListRunningModelsAsync();
models2.Models.Should().NotBeNullOrEmpty();
}

}
}

0 comments on commit d187afc

Please sign in to comment.