added unit test
This commit is contained in:
parent
7ab0a3524f
commit
0355884f35
@ -171,4 +171,4 @@ options:
|
||||
default:
|
||||
description: |
|
||||
Minimum number of units expected to exist before charm will attempt to
|
||||
form a cluster.
|
||||
form a rabbitmq cluster.
|
||||
|
@ -129,3 +129,20 @@ class RelationUtil(TestCase):
|
||||
mock_peer_store_and_set.assert_called_with(
|
||||
relation_settings={'private-address': ipv6_addr},
|
||||
relation_id=None)
|
||||
|
||||
@patch.object(rabbitmq_server_relations, 'related_units')
|
||||
@patch.object(rabbitmq_server_relations, 'relation_ids')
|
||||
@patch.object(rabbitmq_server_relations, 'config')
|
||||
def test_is_sufficient_peers(self, mock_config, mock_relation_ids,
|
||||
mock_related_units):
|
||||
_config = {'min-cluster-size': None}
|
||||
mock_config.side_effect = lambda key: _config.get(key)
|
||||
self.assertTrue(rabbitmq_server_relations.is_sufficient_peers())
|
||||
|
||||
mock_relation_ids.return_value = ['cluster:0']
|
||||
mock_related_units.return_value = ['test/0']
|
||||
_config = {'min-cluster-size': 3}
|
||||
self.assertFalse(rabbitmq_server_relations.is_sufficient_peers())
|
||||
|
||||
mock_related_units.return_value = ['test/0', 'test/1']
|
||||
self.assertTrue(rabbitmq_server_relations.is_sufficient_peers())
|
||||
|
Loading…
Reference in New Issue
Block a user