Skip to content

Commit

Permalink
test: add e2e test for cloud spec
Browse files Browse the repository at this point in the history
  • Loading branch information
IronCore864 committed Apr 8, 2024
1 parent b02cf85 commit 108b1ce
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_e2e/test_cloud_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import ops
import pytest

import scenario


@pytest.fixture(scope="function")
def mycharm():
class MyCharm(ops.CharmBase):
def __init__(self, framework: ops.Framework):
super().__init__(framework)
for evt in self.on.events().values():
self.framework.observe(evt, self._on_event)

def _on_event(self, event):
pass

return MyCharm


def test_get_cloud_spec(mycharm):
cloud_spec = ops.model.CloudSpec.from_dict(
{
"name": "localhost",
"type": "lxd",
"endpoint": "https://127.0.0.1:8443",
"credential": {
"auth-type": "certificate",
"attrs": {
"client-cert": "foo",
"client-key": "bar",
"server-cert": "baz",
},
},
}
)

ctx = scenario.Context(mycharm, meta={"name": "foo"})
with ctx.manager("start", scenario.State(cloud_spec=cloud_spec)) as mgr:
assert mgr.charm.model.get_cloud_spec() == cloud_spec

0 comments on commit 108b1ce

Please sign in to comment.