Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup tests with new snapshot method #122

Merged
merged 2 commits into from
Aug 7, 2022
Merged

Conversation

liamnichols
Copy link
Member

@liamnichols liamnichols commented Aug 7, 2022

Prior to now, the tests would generate and assert snapshots in a relatively verbose way which gets tricky around file paths. This would make my job harder when adjusting behaviour on #88 so instead I decided to clean things up a little.

In this change, I introduce a new snapshot(spec:name:arguments:congifuration:) method and called it in every single test method.

func testEdgecasesRename() throws {
    try snapshot(
        spec: .edgecases,
        name: "edgecases-rename",
        arguments: [
            "--package", "edgecases-rename"
        ],
        configuration: """
        {
            "rename": {
                "properties": {
                    "ContainerA.Child.Child.renameMe": "onlyItRenamed"
                },
                "entities": {
                    "ApiResponse": "APIResponse",
                    "Status": "State"
                }
            }
        }
        """
    )
}

This method then internally handles the --output path and adds a temporary workaround to account for the inconsistencies between --package and --module.

Additionally, this method works to separate the concept of a 'name' and 'package'. Currently, every generated snapshot has a different package name because package name == directory name.

Moving forward, we'll also break that concept so that name == test name and package name == whatever you provide (it doesn't really matter). By doing this, we can use #function and it'll make things simpler. I'll do that in a separate change though.

I also renamed GenerateBaseTests to GenerateTestCase to better distinguish that it's not tests but in fact an XCTestCase subclass/base class to be used by Generate related tests.

@liamnichols liamnichols merged commit 0ba10b9 into main Aug 7, 2022
@liamnichols liamnichols deleted the ln/test-snapshot-method branch August 13, 2022 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant