|
|
|
|
@ -222,6 +222,10 @@ Capsule::table('cloud_network_lines')->insert([
|
|
|
|
|
'code' => 'standard', 'name' => 'Standard', 'is_default' => 0,
|
|
|
|
|
'status' => 'active', 'sort' => 1, 'created_at' => $now,
|
|
|
|
|
'updated_at' => $now],
|
|
|
|
|
['id' => 3, 'region_id' => 2, 'traffic_pool_group_id' => null,
|
|
|
|
|
'code' => 'premium', 'name' => 'Premium', 'is_default' => 0,
|
|
|
|
|
'status' => 'active', 'sort' => 0, 'created_at' => $now,
|
|
|
|
|
'updated_at' => $now],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$created = CloudAdminTrafficPoolService::create([
|
|
|
|
|
@ -234,12 +238,12 @@ $assert($created['item']['mode'] === 'disabled'
|
|
|
|
|
'A new traffic-pool group did not start disabled at revision one.');
|
|
|
|
|
|
|
|
|
|
$mapped = CloudAdminTrafficPoolService::replaceLines($groupId, [
|
|
|
|
|
'line_ids' => [1],
|
|
|
|
|
'line_ids' => [1, 3],
|
|
|
|
|
'expected_revision' => 1,
|
|
|
|
|
]);
|
|
|
|
|
$assert($mapped['item']['line_ids'] === [1]
|
|
|
|
|
$assert($mapped['item']['line_ids'] === [1, 3]
|
|
|
|
|
&& $mapped['item']['revision'] === 2,
|
|
|
|
|
'The line mapping was not saved atomically.');
|
|
|
|
|
'The cross-region line mapping was not saved atomically.');
|
|
|
|
|
|
|
|
|
|
$second = CloudAdminTrafficPoolService::create([
|
|
|
|
|
'code' => 'standard_pool',
|
|
|
|
|
@ -253,12 +257,14 @@ CloudAdminTrafficPoolService::replaceLines($secondId, [
|
|
|
|
|
$expectConflict(
|
|
|
|
|
static fn (): array => CloudAdminTrafficPoolService::replaceLines(
|
|
|
|
|
$groupId,
|
|
|
|
|
['line_ids' => [1, 2], 'expected_revision' => 2]
|
|
|
|
|
['line_ids' => [1, 2, 3], 'expected_revision' => 2]
|
|
|
|
|
),
|
|
|
|
|
'A line owned by another group was partially attached.'
|
|
|
|
|
);
|
|
|
|
|
$assert((int) Capsule::table('cloud_network_lines')->where('id', 1)
|
|
|
|
|
->value('traffic_pool_group_id') === $groupId
|
|
|
|
|
&& (int) Capsule::table('cloud_network_lines')->where('id', 3)
|
|
|
|
|
->value('traffic_pool_group_id') === $groupId
|
|
|
|
|
&& (int) Capsule::table('cloud_network_lines')->where('id', 2)
|
|
|
|
|
->value('traffic_pool_group_id') === $secondId,
|
|
|
|
|
'A failed mapping request left a partial catalog update.');
|
|
|
|
|
|