question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

largeString shouldMatchFile "workflow.yaml"

See original GitHub issue

Please describe the feature you’d like to see including any solutions in mind if you have any

To compare very large strings, it’s easier to write the expected content in a separate file.

https://github.com/krzema12/github-actions-kotlin-dsl/blob/6fc0b3f279ee7372e084545245a08d9e51f36317/library/src/test/kotlin/it/krzeminski/githubactions/IntegrationTest.kt#L25-L39

class IntegrationTest : FunSpec({
    setupShouldMatchFile(
        baseDirectory = File("src/test/resources/integration"),
        normalize = { it.replace("\r\n", "\n") }, // test shouldn't fail on CI running on windows
    )

    test("workflowTest : toYaml()") {
        workflowTest.toYaml() shouldMatchFile "workflowTest.yaml"
    }

}

When the test fails, the error message is:

Files differ in /Users/jmfayard/IdeaProjects/github-actions-kotlin-dsl/library/src/test/resources/integration
Expected: expected/workflowTest.yaml
Actual:     actual/workflowTest.yaml 

That tells me exactly what I need to use IntelliJ Diff tool, the perfect tool to check what happens and fix it.

github-actions-kotlin-dsl_–_workflowTest_yaml__et_New_Issue_·_kotest_kotest

The alternative to put the very long string inside the test is ugly

https://github.com/krzema12/github-actions-kotlin-dsl/blob/main/library/src/test/kotlin/it/krzeminski/githubactions/IntegrationTest.kt#L77-L150

Especially modifying the large expected string is hard.

My implementation is done at https://github.com/krzema12/github-actions-kotlin-dsl/blob/6fc0b3f279ee7372e084545245a08d9e51f36317/library/src/test/kotlin/it/krzeminski/githubactions/kotest/ShouldMatchFile.kt

I fall back to use this shouldBe file.readText() on the CI (for me GitHub Actions) because there I can’t easily compare the content of the actual and the expected file.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jmfayardcommented, May 4, 2022

@Kantis readResource is nice ; when I use IntelliJ diffing tool, I do not only see the diff, I can also directly edit the expected file, accepting or rejecting chunks of the diff. For large files that’s quite convenient. github-actions-kotlin-dsl_–_DockerImage_kt

0reactions
bzarebacommented, Oct 14, 2022

Hi, I’ve submitted a PR for this but I was wondering how to make the Expected file path clickable in IntelliJ. The only way that I found is to get absolute path of that resource file, but it points to the build directory which make no sense in scope of editing this in diff window.

Also Actual file is not clickable on dry run (when that file doesn’t exist in build directory).

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use YAML files with workflows - Dataproc - Google Cloud
Run a workflow using a YAML file · Instantiate a workflow using a YAML file with Dataproc Auto Zone Placement · Import and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found