mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-06 05:58:14 -04:00
fix(service): save switches without saving pending Compose edits (#11985)
This commit is contained in:
@@ -38,7 +38,7 @@ it('ensures applicationParser updates docker_compose_raw from original compose,
|
||||
// Check that docker_compose_raw is set from originalCompose, not cleanedCompose
|
||||
expect($parsersFile)
|
||||
->toContain('$originalYaml = Yaml::parse($originalCompose);')
|
||||
->toContain('$resource->docker_compose_raw = Yaml::dump($originalYaml, 10, 2);')
|
||||
->toContain("\$resource->docker_compose_raw = removeComposeVolumeFieldsPreservingComments(\$originalCompose, \$originalYaml, ['content', 'isDirectory', 'is_directory']);")
|
||||
->not->toContain('$resource->docker_compose_raw = $cleanedCompose;');
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ it('ensures serviceParser updates docker_compose_raw from original compose, not
|
||||
// Check that docker_compose_raw is set from originalCompose within serviceParser
|
||||
expect($serviceParserContent)
|
||||
->toContain('$originalYaml = Yaml::parse($originalCompose);')
|
||||
->toContain('$resource->docker_compose_raw = Yaml::dump($originalYaml, 10, 2);')
|
||||
->toContain("\$resource->docker_compose_raw = removeComposeVolumeFieldsPreservingComments(\$originalCompose, \$originalYaml, ['content', 'isDirectory', 'is_directory']);")
|
||||
->not->toContain('$resource->docker_compose_raw = $cleanedCompose;');
|
||||
});
|
||||
|
||||
@@ -98,3 +98,13 @@ it('ensures docker_compose_raw update is wrapped in try-catch for error handling
|
||||
->toContain('} catch (Exception) {')
|
||||
->toContain('// If parsing fails, keep the original docker_compose_raw unchanged');
|
||||
});
|
||||
|
||||
it('does not reformat legacy raw Compose when no content is removed', function () {
|
||||
$source = file_get_contents(__DIR__.'/../../bootstrap/helpers/shared.php');
|
||||
$parser = substr($source, strpos($source, 'function parseDockerComposeFile('), strpos($source, 'function generate_fluentd_configuration(') - strpos($source, 'function parseDockerComposeFile('));
|
||||
|
||||
expect($parser)
|
||||
->toContain('if ($yaml !== $originalYaml) {')
|
||||
->toContain("data_forget(\$yaml, 'services.*.volumes.*.content')");
|
||||
expect(substr_count($parser, "\$resource->docker_compose_raw = removeComposeVolumeFieldsPreservingComments(\$resource->docker_compose_raw, \$yaml, ['content']);"))->toBe(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user