Files
coolify/tests/Unit/CloneResourceNameTest.php
T
Andras Bacsai bb1fada600 fix(clone): replace the clone suffix instead of adding one for each clone
Cloning a clone added another "-clone-<id>" to the name, so after about
seven clones the name was longer than 255 characters and the insert failed.

Closes #9976
2026-10-27 17:06:52 +01:00

26 lines
992 B
PHP

<?php
it('adds a clone suffix to the source name', function () {
expect(clone_resource_name('Gitea Runner', 'abc123def456ghi789jkl012'))
->toBe('Gitea Runner-clone-abc123def456ghi789jkl012');
});
it('replaces the clone suffixes of earlier clones', function () {
$name = 'Gitea Runner-clone-sy2cojnseswr8szrpj1omsgw-clone-yvj9kdc2xuff8td0f0mps7eq-clone-ab12cd3';
expect(clone_resource_name($name, 'newid000000000000000000a'))
->toBe('Gitea Runner-clone-newid000000000000000000a');
});
it('keeps a name that only contains the word clone', function () {
expect(clone_resource_name('my-clone-db', 'abc123def456ghi789jkl012'))
->toBe('my-clone-db-clone-abc123def456ghi789jkl012');
});
it('keeps the clone name within the 255 characters of the name column', function () {
$name = clone_resource_name(str_repeat('a', 255), 'abc123def456ghi789jkl012');
expect($name)->toHaveLength(255)
->toEndWith('-clone-abc123def456ghi789jkl012');
});