|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @since Oct 2023 |
| 4 | + * @author Haydar KULEKCI <haydarkulekci@gmail.com> |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Qdrant\Tests\Unit\Models\Request\ClusterUpdate; |
| 8 | + |
| 9 | +use PHPUnit\Framework\TestCase; |
| 10 | +use Qdrant\Exception\InvalidArgumentException; |
| 11 | +use Qdrant\Models\Request\ClusterUpdate\AbortTransferOperation; |
| 12 | +use Qdrant\Models\Request\UpdateCollectionCluster; |
| 13 | + |
| 14 | +class AbortTransferOperationTest extends TestCase |
| 15 | +{ |
| 16 | + public function testBasic(): void |
| 17 | + { |
| 18 | + $config = new AbortTransferOperation(0, 2, 1); |
| 19 | + |
| 20 | + $this->assertEquals([ |
| 21 | + 'shard_id' => 0, |
| 22 | + 'to_peer_id' => 2, |
| 23 | + 'from_peer_id' => 1, |
| 24 | + ], $config->toArray()); |
| 25 | + } |
| 26 | + |
| 27 | + public function testWithUpdateCollectionCluster() |
| 28 | + { |
| 29 | + $config = new UpdateCollectionCluster( |
| 30 | + new AbortTransferOperation(0, 2, 1) |
| 31 | + ); |
| 32 | + |
| 33 | + $this->assertEquals([ |
| 34 | + 'abort_transfer' => [ |
| 35 | + 'shard_id' => 0, |
| 36 | + 'to_peer_id' => 2, |
| 37 | + 'from_peer_id' => 1, |
| 38 | + ] |
| 39 | + ], $config->toArray()); |
| 40 | + } |
| 41 | + |
| 42 | + public function testWithMethod(): void |
| 43 | + { |
| 44 | + $config = (new AbortTransferOperation(0, 2, 1)) |
| 45 | + ->setMethod('snapshot'); |
| 46 | + |
| 47 | + $this->assertEquals([ |
| 48 | + 'shard_id' => 0, |
| 49 | + 'to_peer_id' => 2, |
| 50 | + 'from_peer_id' => 1, |
| 51 | + 'method' => 'snapshot' |
| 52 | + ], $config->toArray()); |
| 53 | + } |
| 54 | + |
| 55 | + public function testWithInvalidMethod(): void |
| 56 | + { |
| 57 | + $this->expectException(InvalidArgumentException::class); |
| 58 | + $this->expectExceptionMessage('Method could be snapshot or stream_record for operations'); |
| 59 | + $config = (new AbortTransferOperation(0, 2, 1)) |
| 60 | + ->setMethod('foo'); |
| 61 | + } |
| 62 | +} |
0 commit comments