Skip to content

Commit

Permalink
Enhance YAML Export: Make Project Description Multiline (#2553)
Browse files Browse the repository at this point in the history
* Make project description multiline in project.yaml

---------

Co-authored-by: Stuart Corbishley <corbish@gmail.com>
  • Loading branch information
elias-ba and stuartc authored Oct 8, 2024
1 parent 9e41538 commit 8db94e3
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ and this project adheres to

### Changed

- Make project description multiline in project.yaml
[#2534](https://github.com/OpenFn/lightning/issues/2534)
- Do not track partition timestamps when ingesting Kafka messages.
[#2531] (https://github.com/OpenFn/lightning/issues/2531)
[#2531](https://github.com/OpenFn/lightning/issues/2531)
- Always use the `initial_offset_reset_policy` when enabling a Kafka pipeline.
[#2531] (https://github.com/OpenFn/lightning/issues/2531)
[#2531](https://github.com/OpenFn/lightning/issues/2531)

### Fixed

Expand Down Expand Up @@ -334,7 +336,7 @@ and this project adheres to
- Kafka messages without keys are synchronously converted into a Workorder,
Dataclip and Run. Messages with keys are stored as TriggerKafkaMessage
records, however the code needed to process them has been disabled, pending
removal. [#2351] (https://github.com/OpenFn/lightning/issues/2351)
removal. [#2351](https://github.com/OpenFn/lightning/issues/2351)
## [v2.7.14] - 2024-08-05
Expand Down
3 changes: 3 additions & 0 deletions lib/lightning/export_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ defmodule Lightning.ExportUtils do
:body ->
"body: |\n#{indent_multiline_value(v, i)}"

:description ->
"description: |\n#{indent_multiline_value(v, i)}"

:adaptor ->
"#{k}: '#{v}'"

Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/canonical_project.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: a-test-project
description: This is only a test
description: |
This is only a test
credentials:
cannonical-user@lightning.com-new-credential:
name: new credential
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cli_deploy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defmodule Lightning.CliDeployTest do
|> Lightning.Repo.preload(workflows: [:jobs, :triggers, :edges])

assert project.name == "a-test-project"
assert project.description == "This is only a test"
assert project.description == "This is only a test\n"

assert Enum.count(project.workflows) == 2

Expand Down
54 changes: 54 additions & 0 deletions test/lightning/projects_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,60 @@ defmodule Lightning.ProjectsTest do
"condition_expression: |\n #{js_expression}"
end

test "project descriptions with multiline and special characters are correctly represented" do
project =
insert(:project,
name: "project_multiline_special",
description: """
This is a multiline description.
It includes special characters: :, #, &, *, ?, |, -, <, >, =, !, %, @, *, &, ?.
Also, YAML indicators: *alias, &anchor, ?key, !tag.
Line breaks and special characters should be preserved.
"""
)

assert {:ok, generated_yaml} = Projects.export_project(:yaml, project.id)

expected_yaml = """
name: project_multiline_special
description: |
This is a multiline description.
It includes special characters: :, #, &, *, ?, |, -, <, >, =, !, %, @, *, &, ?.
Also, YAML indicators: *alias, &anchor, ?key, !tag.
Line breaks and special characters should be preserved.
"""

assert generated_yaml =~ expected_yaml
end

test "projects with empty and nil descriptions are correctly represented" do
project_empty =
insert(:project, name: "project_empty_description", description: "")

assert {:ok, generated_yaml} =
Projects.export_project(:yaml, project_empty.id)

expected_yaml = """
name: project_empty_description
description: |
"""

assert generated_yaml =~ expected_yaml

project_nil =
insert(:project, name: "project_nil_description", description: nil)

assert {:ok, generated_yaml} =
Projects.export_project(:yaml, project_nil.id)

expected_yaml = """
name: project_nil_description
description: null
"""

assert generated_yaml =~ expected_yaml
end

test "exports canonical project" do
project =
canonical_project_fixture(
Expand Down

0 comments on commit 8db94e3

Please sign in to comment.