mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
- database import: add keep_owners (restore PostgreSQL owners and privileges) and sqlite_database (pick the target SQLite file) to the API, OpenAPI spec, and import form - oauth: require password confirmation and support team selection on OAuth login - remote process: send team broadcast events to the team of the server that ran the process instead of the causer's user id - servers API: handle the legacy build server setting - compose: support parent bind paths and volume driver options - dns: improve record hints and provider management - notifications: fix throttling and missing backup notifications - ui: rework the confirmation modal - add feature and unit tests for the new behavior
91 lines
3.2 KiB
PHP
91 lines
3.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Tests for GitHub issue #7802: volume mappings from repo content in Preview Deployments.
|
|
*
|
|
* Behavioral tests for addPreviewDeploymentSuffix and related helper functions.
|
|
*
|
|
* Note: The parser functions (applicationParser, serviceParser) and
|
|
* ApplicationDeploymentJob methods require database-persisted models with
|
|
* relationships (Application->destination->server, etc.), making them
|
|
* unsuitable for unit tests. Integration tests for those paths belong
|
|
* in tests/Feature/.
|
|
*/
|
|
describe('addPreviewDeploymentSuffix', function () {
|
|
it('appends -pr-N suffix for non-zero pull request id', function () {
|
|
expect(addPreviewDeploymentSuffix('myvolume', 3))->toBe('myvolume-pr-3');
|
|
});
|
|
|
|
it('returns name unchanged when pull request id is zero', function () {
|
|
expect(addPreviewDeploymentSuffix('myvolume', 0))->toBe('myvolume');
|
|
});
|
|
|
|
it('handles pull request id of 1', function () {
|
|
expect(addPreviewDeploymentSuffix('scripts', 1))->toBe('scripts-pr-1');
|
|
});
|
|
|
|
it('handles large pull request ids', function () {
|
|
expect(addPreviewDeploymentSuffix('data', 9999))->toBe('data-pr-9999');
|
|
});
|
|
|
|
it('handles names with dots and slashes', function () {
|
|
expect(addPreviewDeploymentSuffix('./scripts', 2))->toBe('./scripts-pr-2');
|
|
});
|
|
|
|
it('handles names with existing hyphens', function () {
|
|
expect(addPreviewDeploymentSuffix('my-volume-name', 5))->toBe('my-volume-name-pr-5');
|
|
});
|
|
|
|
it('handles empty name with non-zero pr id', function () {
|
|
expect(addPreviewDeploymentSuffix('', 1))->toBe('-pr-1');
|
|
});
|
|
|
|
it('handles uuid-prefixed volume names', function () {
|
|
$uuid = 'abc123_my-volume';
|
|
expect(addPreviewDeploymentSuffix($uuid, 7))->toBe('abc123_my-volume-pr-7');
|
|
});
|
|
|
|
it('defaults pull_request_id to 0', function () {
|
|
expect(addPreviewDeploymentSuffix('myvolume'))->toBe('myvolume');
|
|
});
|
|
});
|
|
|
|
describe('sourceIsLocal', function () {
|
|
it('detects relative paths starting with dot-slash', function () {
|
|
expect(sourceIsLocal(str('./scripts')))->toBeTrue();
|
|
});
|
|
|
|
it('detects absolute paths starting with slash', function () {
|
|
expect(sourceIsLocal(str('/var/data')))->toBeTrue();
|
|
});
|
|
|
|
it('detects tilde paths', function () {
|
|
expect(sourceIsLocal(str('~/data')))->toBeTrue();
|
|
});
|
|
|
|
it('detects parent directory paths', function () {
|
|
expect(sourceIsLocal(str('../config')))->toBeTrue();
|
|
});
|
|
|
|
it('returns false for named volumes', function () {
|
|
expect(sourceIsLocal(str('myvolume')))->toBeFalse();
|
|
});
|
|
});
|
|
|
|
describe('replaceLocalSource', function () {
|
|
it('replaces dot-slash prefix with target path', function () {
|
|
$result = replaceLocalSource(str('./scripts'), str('/app'));
|
|
expect((string) $result)->toBe('/app/scripts');
|
|
});
|
|
|
|
it('resolves dot-dot-slash prefix against the parent of the target path', function () {
|
|
$result = replaceLocalSource(str('../config'), str('/app'));
|
|
expect((string) $result)->toBe('/config');
|
|
});
|
|
|
|
it('replaces tilde prefix with target path', function () {
|
|
$result = replaceLocalSource(str('~/data'), str('/app'));
|
|
expect((string) $result)->toBe('/app/data');
|
|
});
|
|
});
|