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

Add support for passing charmcraft.yaml as metadata to testing.Context #1424

Open
tonyandrewmeyer opened this issue Oct 10, 2024 · 0 comments
Labels
25.04 feature New feature or request testing Related to ops.testing

Comments

@tonyandrewmeyer
Copy link
Contributor

Description

Charmcraft.yaml (replacing metadata.yaml) now removes the need to have different files for metadata, config, and actions. When providing metadata in the charmcraft.yaml format, we get a InconsistentScenarioError error because the config option is not recognized.

METADATA = yaml.safe_load(Path("tests/unit/charms/tls_certificates_interface/v4/dummy_requirer_charm/charmcraft.yaml").read_text())
state_in = scenario.State(
    config={"common_name": "example.com"},
)
ctx = scenario.Context(
    charm_type=DummyTLSCertificatesRequirerCharm,
    meta=METADATA,
)

Logs

scenario.runtime.InconsistentScenarioError: Inconsistent scenario. The following errors were found: config option 'common_name' in state.config but not specified in config.yaml.

Desired state

self.ctx = scenario.Context(
    charm_type=DummyTLSCertificatesRequirerCharm,
    meta=METADATA,
)

Workaround

self.ctx = scenario.Context(
    charm_type=DummyTLSCertificatesRequirerCharm,
    meta=METADATA,
    config=METADATA["config"],
    actions=METADATA["actions"],
)

Moved from canonical/ops-scenario#156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
25.04 feature New feature or request testing Related to ops.testing
Projects
None yet
Development

No branches or pull requests

2 participants