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

Means of testing relation data #81

Open
PietroPasotti opened this issue May 31, 2022 · 0 comments · May be fixed by #82
Open

Means of testing relation data #81

PietroPasotti opened this issue May 31, 2022 · 0 comments · May be fixed by #82

Comments

@PietroPasotti
Copy link
Contributor

As a user, I would like to have some utility to test the contents of relation databags in itests.

Something like:

async def test_relate(ops_test: OpsTest):
    await ops_test.juju('relate', 'spring-music:ingress', 'traefik-k8s:ingress')
    async with ops_test.fast_forward():
        await ops_test.model.wait_for_idle(['traefik-k8s', 'spring-music'])

    data = await ops_test.get_relation_data(requirer_endpoint='spring-music/0:ingress',
                                   provider_endpoint='traefik-k8s/0:ingress')

    model = ops_test.current_alias
    assert data.requirer.application_data == {
        'host': f'spring-music.{model}.svc.cluster.local',
        'model': model,
        'name': 'spring-music/0',
        'port': '8080',
    }
    
    assert data.provider.unit_data == {'foo': 'bar'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant