Skip to content

Document testing for custom FileConfigSnapshot implementations #127

@mattt

Description

@mattt

When implementing an external provider package (e.g., TOMLProvider, it's unclear how to implement a compatibility suite on par with the ones for built-in JSON and YAML providers.

Specifically, for the compat() test, both JSONFileProviderTests and YAMLFileProviderTests declare configurations with string literals and use InMemoryFileSystem and pass that to ProviderCompatTest. However, InMemoryFileSystem lives in ConfigurationTestingInternal and is not exposed publicly.

I found a different solution, loading a file from the package resource bundle, but that wasn't obvious.

private let resourcesPath = FilePath(try! #require(Bundle.module.path(forResource: "Resources", ofType: nil)))
let tomlConfigFile = resourcesPath.appending("config.toml")

It'd be great to document this pattern in swift-configuration docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/documentationImprovements or additions to documentation.kind/enhancementImprovements to existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions