diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5cfb9e8..2581f43 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,6 +12,8 @@ on: env: DENSE_UPSTASH_VECTOR_REST_URL: ${{ secrets.DENSE_UPSTASH_VECTOR_REST_URL }} DENSE_UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.DENSE_UPSTASH_VECTOR_REST_TOKEN }} + DENSE_EMBEDDING_UPSTASH_VECTOR_REST_URL: ${{ secrets.DENSE_EMBEDDING_UPSTASH_VECTOR_REST_URL }} + DENSE_EMBEDDING_UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.DENSE_EMBEDDING_UPSTASH_VECTOR_REST_TOKEN }} jobs: test: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e6af434..3fd68a8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -43,7 +43,11 @@ + + + + diff --git a/tests/Concerns/UsesDenseIndexWithEmbedding.php b/tests/Concerns/UsesDenseIndexWithEmbedding.php new file mode 100644 index 0000000..dc00022 --- /dev/null +++ b/tests/Concerns/UsesDenseIndexWithEmbedding.php @@ -0,0 +1,33 @@ +index = new Index( + url: getenv('DENSE_EMBEDDING_UPSTASH_VECTOR_REST_URL'), + token: getenv('DENSE_EMBEDDING_UPSTASH_VECTOR_REST_TOKEN'), + ); + + $this->namespace = $this->index->namespace(bin2hex(random_bytes(32))); + } + + public function tearDown(): void + { + $this->namespace->delete(); + + parent::tearDown(); + } +} diff --git a/tests/Dense/Operations/UpsertDataTest.php b/tests/Dense/Operations/UpsertDataTest.php new file mode 100644 index 0000000..b04b7f5 --- /dev/null +++ b/tests/Dense/Operations/UpsertDataTest.php @@ -0,0 +1,43 @@ +namespace->upsertData(new DataUpsert( + id: '1', + data: 'The capital of Japan is Tokyo', + )); + + $this->waitForIndex($this->namespace); + + $info = $this->namespace->getNamespaceInfo(); + + $this->assertSame(1, $info->vectorCount); + } + + public function test_upsert_many_data(): void + { + $this->namespace->upsertDataMany([ + new DataUpsert(id: '1', data: 'The capital of Japan is Tokyo'), + new DataUpsert(id: '2', data: 'The capital of France is Paris'), + new DataUpsert(id: '3', data: 'The capital of Germany is Berlin'), + ]); + + $this->waitForIndex($this->namespace); + + $info = $this->namespace->getNamespaceInfo(); + + $this->assertSame(3, $info->vectorCount); + } +}