Unit tests

This commit is contained in:
Gustavo Sanchez 2021-11-30 15:15:05 -04:00
parent 8004acd6c7
commit f1e906d4d0
No known key found for this signature in database
GPG Key ID: CB6FDA23F1075685

View File

@ -25,19 +25,27 @@ class TestCinderSolidfireCharm(unittest.TestCase):
self.addCleanup(self.harness.cleanup) self.addCleanup(self.harness.cleanup)
self.harness.begin() self.harness.begin()
self.harness.set_leader(True) self.harness.set_leader(True)
backend = self.harness.add_relation('storage-backend', 'cinder') relation_id = self.harness.add_relation('storage-backend', 'cinder')
self.harness.update_config({'volume-backend-name': 'test'}) self.harness.add_relation_unit(relation_id, 'cinder/0')
self.harness.add_relation_unit(backend, 'cinder/0')
def test_cinder_base(self): def test_base(self):
self.assertEqual( self.assertEqual(
self.harness.framework.model.app.name, self.harness.framework.model.app.name,
'cinder-solidfire') 'cinder-solidfire')
# Test that charm is active upon installation.
self.harness.update_config({}) self.harness.update_config({})
self.assertTrue(isinstance( self.assertTrue(isinstance(
self.harness.model.unit.status, ActiveStatus)) self.harness.model.unit.status, ActiveStatus))
def test_cinder_configuration(self): def test_configuration(self):
# Add check here that configuration is as expected. test_config = {
pass 'volume-backend-name': 'cinder_solidfire_test',
'san-ip': '10.0.0.11',
'san-login': 'username',
'san-password': 'password',
}
config = self.harness.model.config
self.harness.update_config(test_config)
for k in test_config:
self.assertEqual(test_config[k], config[k])