diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-22 10:56:29 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-23 13:07:02 +0300 |
| commit | 04acd3d6b9a95ff49d430eaf4f65aabc25282d88 (patch) | |
| tree | 00e643a8a5678d4c8dcdce77afe5604860e21612 /src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php | |
| parent | 0b466b90271553d0c4f620e326305453a4b23dd7 (diff) | |
| download | phorge-elasticsearch-modern-04acd3d6b9a95ff49d430eaf4f65aabc25282d88.tar.gz phorge-elasticsearch-modern-04acd3d6b9a95ff49d430eaf4f65aabc25282d88.zip | |
Engine: Add setVersion() with strict validation
Engine accepts only versions 7 and above (covering ES 7.x, 8.x, and
OpenSearch 1.x/2.x/3.x via the typeless API). Anything below 7
raises with a clear message pointing at the bundled engine for ES 5
users.
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to 'src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php')
| -rw-r--r-- | src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php new file mode 100644 index 0000000..7a41ca1 --- /dev/null +++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php @@ -0,0 +1,38 @@ +<?php + +final class VyOSElasticModernFulltextStorageEngineTestCase + extends PhutilTestCase { + + public function testSetVersionAcceptsSevenAndAbove() { + foreach (array(7, 8, 9, 100) as $v) { + $engine = new VyOSElasticModernFulltextStorageEngine(); + $caught = null; + try { + $engine->setVersion($v); + } catch (Exception $e) { + $caught = $e; + } + $this->assertEqual( + null, + $caught, + pht('Expected no exception for version=%d.', $v)); + $this->assertEqual($v, $engine->getVersion()); + } + } + + public function testSetVersionRejectsBelowSeven() { + foreach (array(0, 1, 2, 5, 6) as $v) { + $engine = new VyOSElasticModernFulltextStorageEngine(); + $caught = null; + try { + $engine->setVersion($v); + } catch (Exception $e) { + $caught = $e; + } + $this->assertTrue( + $caught !== null, + pht('Expected an exception for version=%d.', $v)); + } + } + +} |
