Browse Source

Tests: remove_curator_from_group failure cases coverage added

iorveth 4 years ago
parent
commit
80861f44bb

+ 2 - 2
runtime-modules/content-directory/src/tests/add_curator_to_group.rs

@@ -49,7 +49,7 @@ fn add_curator_to_group_lead_auth_failed() {
         // Events number before tested call
         let number_of_events_before_call = System::events().len();
 
-        // Add curator to group
+        // Make an attempt to add curator to group from non lead origin
         let add_curator_to_group_result = add_curator_to_group(
             FIRST_MEMBER_ORIGIN,
             FIRST_CURATOR_GROUP_ID,
@@ -73,7 +73,7 @@ fn add_curator_to_non_existent_group() {
         // Events number before tested call
         let number_of_events_before_call = System::events().len();
 
-        // Add curator to group
+        // Make an attempt to add curator to group that does not exist
         let add_curator_to_group_result =
             add_curator_to_group(LEAD_ORIGIN, FIRST_CURATOR_GROUP_ID, FIRST_CURATOR_ID);
 

+ 79 - 0
runtime-modules/content-directory/src/tests/remove_curator_from_group.rs

@@ -50,3 +50,82 @@ fn remove_curator_from_group_success() {
         );
     })
 }
+
+#[test]
+fn remove_curator_from_group_lead_auth_failed() {
+    with_test_externalities(|| {
+        // Add curator group
+        assert_ok!(add_curator_group(LEAD_ORIGIN));
+
+        // Add curator to group
+        assert_ok!(add_curator_to_group(
+            LEAD_ORIGIN,
+            FIRST_CURATOR_GROUP_ID,
+            FIRST_CURATOR_ID
+        ));
+
+        // Runtime tested state before call
+
+        // Events number before tested call
+        let number_of_events_before_call = System::events().len();
+
+        // Make an attempt to remove curator from group using non lead origin
+        let remove_curator_from_group_result = remove_curator_from_group(
+            FIRST_MEMBER_ORIGIN,
+            FIRST_CURATOR_GROUP_ID,
+            FIRST_CURATOR_ID,
+        );
+
+        // Failure checked
+        assert_failure(
+            remove_curator_from_group_result,
+            ERROR_LEAD_AUTH_FAILED,
+            number_of_events_before_call,
+        );
+    })
+}
+
+#[test]
+fn remove_curator_from_group_curator_is_not_a_member() {
+    with_test_externalities(|| {
+        // Add curator group
+        assert_ok!(add_curator_group(LEAD_ORIGIN));
+
+        // Runtime tested state before call
+
+        // Events number before tested call
+        let number_of_events_before_call = System::events().len();
+
+        // Make an attempt to remove curator that does not added to the provided curator group
+        let remove_curator_from_group_result =
+            remove_curator_from_group(LEAD_ORIGIN, FIRST_CURATOR_GROUP_ID, FIRST_CURATOR_ID);
+
+        // Failure checked
+        assert_failure(
+            remove_curator_from_group_result,
+            ERROR_CURATOR_IS_NOT_A_MEMBER_OF_A_GIVEN_CURATOR_GROUP,
+            number_of_events_before_call,
+        );
+    })
+}
+
+#[test]
+fn remove_curator_from_non_existent_group() {
+    with_test_externalities(|| {
+        // Runtime tested state before call
+
+        // Events number before tested call
+        let number_of_events_before_call = System::events().len();
+
+        // Make an attempt to remove curator from group using non lead origin
+        let remove_curator_from_group_result =
+            remove_curator_from_group(LEAD_ORIGIN, FIRST_CURATOR_GROUP_ID, FIRST_CURATOR_ID);
+
+        // Failure checked
+        assert_failure(
+            remove_curator_from_group_result,
+            ERROR_CURATOR_GROUP_DOES_NOT_EXIST,
+            number_of_events_before_call,
+        );
+    })
+}

+ 1 - 1
runtime-modules/content-directory/src/tests/remove_curator_group.rs

@@ -96,7 +96,7 @@ fn curator_group_removal_forbidden() {
         // Events number before tested call
         let number_of_events_before_call = System::events().len();
 
-        // An attemt to remove non existent curator group
+        // An attemt to remove curator group, that have classes maintained
         let remove_curator_group_result = remove_curator_group(LEAD_ORIGIN, FIRST_CURATOR_ID);
 
         // Failure checked

+ 1 - 1
runtime-modules/content-directory/src/tests/set_curator_group_status.rs

@@ -70,7 +70,7 @@ fn set_curator_group_status_for_non_existent_curator_group() {
         // Events number before tested call
         let number_of_events_before_call = System::events().len();
 
-        // An attemt to change curator group status for_non existent curator group
+        // An attemt to change curator group status for non existent curator group
         let set_curator_group_status_result =
             set_curator_group_status(LEAD_ORIGIN, FIRST_CURATOR_GROUP_ID, true);