| @@ 82-117 (lines=36) @@ | ||
| 79 | ); |
|
| 80 | } |
|
| 81 | ||
| 82 | public function testSwitchIndexMustFailDueToPutAliasException(): void |
|
| 83 | { |
|
| 84 | $this->mock(Client::class, function (MockInterface $mock) { |
|
| 85 | $mock->shouldReceive('indices') |
|
| 86 | ->times(2) |
|
| 87 | ->andReturn( |
|
| 88 | $this->mock(IndicesNamespace::class, function (MockInterface $mock) { |
|
| 89 | $mock->shouldReceive('exists') |
|
| 90 | ->once() |
|
| 91 | ->andReturn(true); |
|
| 92 | ||
| 93 | $mock->shouldReceive('putAlias') |
|
| 94 | ->once() |
|
| 95 | ->andThrow( |
|
| 96 | new Exception( |
|
| 97 | 'error adding new index to alias exception' |
|
| 98 | ) |
|
| 99 | ); |
|
| 100 | ||
| 101 | $mock->shouldNotReceive('deleteAlias'); |
|
| 102 | }) |
|
| 103 | ); |
|
| 104 | }); |
|
| 105 | ||
| 106 | $this->artisan( |
|
| 107 | 'laravel-elasticsearch:utils:alias-switch-index', |
|
| 108 | [ |
|
| 109 | 'new-index-name' => 'new_valid_index_name', |
|
| 110 | 'old-index-name' => 'old_valid_index_name', |
|
| 111 | 'alias-name' => 'valid_alias_name', |
|
| 112 | ] |
|
| 113 | )->assertExitCode(1) |
|
| 114 | ->expectsOutput( |
|
| 115 | 'Error switching indexes - new index: new_valid_index_name, old index: old_valid_index_name in alias valid_alias_name, exception message: error adding new index to alias exception.' |
|
| 116 | ); |
|
| 117 | } |
|
| 118 | ||
| 119 | public function testSwitchIndexMustFailDueToDeleteAliasException(): void |
|
| 120 | { |
|
| @@ 119-157 (lines=39) @@ | ||
| 116 | ); |
|
| 117 | } |
|
| 118 | ||
| 119 | public function testSwitchIndexMustFailDueToDeleteAliasException(): void |
|
| 120 | { |
|
| 121 | $this->mock(Client::class, function (MockInterface $mock) { |
|
| 122 | $mock->shouldReceive('indices') |
|
| 123 | ->times(3) |
|
| 124 | ->andReturn( |
|
| 125 | $this->mock(IndicesNamespace::class, function (MockInterface $mock) { |
|
| 126 | $mock->shouldReceive('exists') |
|
| 127 | ->once() |
|
| 128 | ->andReturn(true); |
|
| 129 | ||
| 130 | $mock->shouldReceive('putAlias') |
|
| 131 | ->once() |
|
| 132 | ->andReturn([]); |
|
| 133 | ||
| 134 | $mock->shouldReceive('deleteAlias') |
|
| 135 | ->once() |
|
| 136 | ->andThrow( |
|
| 137 | new Exception( |
|
| 138 | 'error removing old index from alias exception' |
|
| 139 | ) |
|
| 140 | ); |
|
| 141 | ||
| 142 | }) |
|
| 143 | ); |
|
| 144 | }); |
|
| 145 | ||
| 146 | $this->artisan( |
|
| 147 | 'laravel-elasticsearch:utils:alias-switch-index', |
|
| 148 | [ |
|
| 149 | 'new-index-name' => 'new_valid_index_name', |
|
| 150 | 'old-index-name' => 'old_valid_index_name', |
|
| 151 | 'alias-name' => 'valid_alias_name', |
|
| 152 | ] |
|
| 153 | )->assertExitCode(1) |
|
| 154 | ->expectsOutput( |
|
| 155 | 'Error switching indexes - new index: new_valid_index_name, old index: old_valid_index_name in alias valid_alias_name, exception message: error removing old index from alias exception.' |
|
| 156 | ); |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * @dataProvider invalidIndexNameDataProvider |
|