Skip to content

Commit

Permalink
Add Embedder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ManyTheFish committed Oct 8, 2024
1 parent 39d4ccd commit 3db3869
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/Settings/EmbeddersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace Tests\Settings;

use Meilisearch\Endpoints\Indexes;
use Meilisearch\Http\Client;
use Tests\TestCase;

final class EmbeddersTest extends TestCase
{
private Indexes $index;

public const DEFAULT_EMBEDDER = null;

protected function setUp(): void
{
parent::setUp();
$http = new Client($this->host, getenv('MEILISEARCH_API_KEY'));
$http->patch('/experimental-features', ['vectorStore' => true]);
$this->index = $this->createEmptyIndex($this->safeIndexName());
}

public function testGetDefaultEmbedders(): void
{
$response = $this->index->getEmbedders();

self::assertSame(self::DEFAULT_EMBEDDER, $response);
}

public function testUpdateEmbedders(): void
{
$newEmbedders = ['manual' => ['source' => 'userProvided', 'dimensions' => 3, 'binaryQuantized' => true]];

$promise = $this->index->updateEmbedders($newEmbedders);

$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

$embedders = $this->index->getEmbedders();

self::assertSame($newEmbedders, $embedders);
}

public function testResetEmbedders(): void
{
$promise = $this->index->resetEmbedders();

$this->assertIsValidPromise($promise);

$this->index->waitForTask($promise['taskUid']);
$embedders = $this->index->getEmbedders();

self::assertSame(self::DEFAULT_EMBEDDER, $embedders);
}
}

0 comments on commit 3db3869

Please sign in to comment.