8
func Test_removing_a_profile_deletes_associated_configuration_entries(t *testing.T) {
13
err = initializeDbObject(d, ":memory:")
16
// Insert a container and a related profile. Dont't forget that the profile
17
// we insert is profile ID 2 (there is a default profile already).
19
INSERT INTO containers (name, architecture, type) VALUES ('thename', 1, 1);
20
INSERT INTO profiles (name) VALUES ('theprofile');
21
INSERT INTO containers_profiles (container_id, profile_id) VALUES (1, 2);
22
INSERT INTO profiles_devices (name, profile_id) VALUES ('somename', 2);
23
INSERT INTO profiles_config (key, value, profile_id) VALUES ('thekey', 'thevalue', 2);
24
INSERT INTO profiles_devices_config (profile_device_id, key, value) VALUES (1, 'something', 'boring');`
26
_, err = db.Exec(statements)
31
// Delete the profile we just created with dbProfileDelete
32
err = dbProfileDelete(db, "theprofile")
37
// Make sure there are 0 profiles_devices entries left.
38
devices, err := dbDevices(d.db, "theprofile", true)
42
if len(devices) != 0 {
43
t.Errorf("Deleting a profile didn't delete the related profiles_devices! There are %d left", len(devices))
46
// Make sure there are 0 profiles_config entries left.
47
config, err := dbProfileConfig(d.db, "theprofile")
49
t.Fatal("found the profile!")
53
t.Errorf("Deleting a profile didn't delete the related profiles_config! There are %d left", len(config))