Parcourir la source

Move set_lead test from forum to the bureaucracy

Shamil Gadelshin il y a 4 ans
Parent
commit
bc315c1a2f

+ 6 - 14
runtime-modules/bureaucracy/src/tests/mock.rs

@@ -6,7 +6,7 @@ use sr_primitives::{
 };
 use srml_support::{impl_outer_origin, parameter_types};
 
-use crate::{Instance1, Trait};
+use crate::{Instance1, Module, Trait};
 
 impl_outer_origin! {
         pub enum Origin for Test {}
@@ -25,15 +25,15 @@ parameter_types! {
     pub const CreationFee: u32 = 0;
 }
 
-// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
+// Workaround for https://github.com/rust-lang/rust/issues/26925 - remove when sorted.
 #[derive(Clone, PartialEq, Eq, Debug)]
 pub struct Test;
 
 impl system::Trait for Test {
     type Origin = Origin;
+    type Call = ();
     type Index = u64;
     type BlockNumber = u64;
-    type Call = ();
     type Hash = H256;
     type Hashing = BlakeTwo256;
     type AccountId = u64;
@@ -90,9 +90,9 @@ impl balances::Trait for Test {
     type Balance = u64;
     type OnFreeBalanceZero = ();
     type OnNewAccount = ();
-    type Event = ();
-    type DustRemoval = ();
     type TransferPayment = ();
+    type DustRemoval = ();
+    type Event = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
@@ -104,10 +104,7 @@ impl Trait<Instance1> for Test {
     type Event = ();
 }
 
-// use crate::Instance2;
-//
-// type Bureaucracy1 = Module<Test, Instance1>;
-// type Bureaucracy2 = Module<Test, Instance2>;
+pub type Bureaucracy1 = Module<Test, Instance1>;
 
 pub fn build_test_externalities() -> runtime_io::TestExternalities {
     let t = system::GenesisConfig::default()
@@ -116,8 +113,3 @@ pub fn build_test_externalities() -> runtime_io::TestExternalities {
 
     t.into()
 }
-
-#[test]
-fn test_instances_storage_separation() {
-    build_test_externalities().execute_with(|| {});
-}

+ 30 - 0
runtime-modules/bureaucracy/src/tests/mod.rs

@@ -1 +1,31 @@
 mod mock;
+
+use crate::types::Lead;
+use mock::{build_test_externalities, Bureaucracy1};
+use system::RawOrigin;
+
+#[test]
+fn set_forum_sudo_set() {
+    build_test_externalities().execute_with(|| {
+        // Ensure that lead is default
+        assert_eq!(Bureaucracy1::current_lead(), None);
+
+        let lead_account_id = 1;
+        let lead_member_id = 1;
+
+        // Set lead
+        assert_eq!(
+            Bureaucracy1::set_lead(RawOrigin::Root.into(), lead_member_id, lead_account_id),
+            Ok(())
+        );
+
+        let lead = Lead {
+            member_id: lead_member_id,
+            role_account_id: lead_account_id,
+        };
+
+        assert_eq!(Bureaucracy1::current_lead(), Some(lead));
+
+        // event emitted?!
+    });
+}

+ 0 - 58
runtime-modules/forum/src/tests.rs

@@ -9,64 +9,6 @@ use srml_support::{assert_err, assert_ok};
 * NB!: No test checks for event emission!!!!
 */
 
-/*
- * set_forum_sudo
- * ==============================================================================
- *
- * Missing cases
- *
- * set_forum_bad_origin
- *
- */
-
-// #[test] //TODO - restore forum_sudo
-// fn set_forum_sudo_unset() {
-//     let config = default_genesis_config();
-//
-//     build_test_externalities(config).execute_with(|| {
-//         // Ensure that forum sudo is default
-//         assert_eq!(TestForumModule::forum_sudo(), Some(33));
-//
-//         // Unset forum sudo
-//         assert_ok!(TestForumModule::set_forum_sudo(
-//             mock_origin(OriginType::Root),
-//             None
-//         ));
-//
-//         // Sudo no longer set
-//         assert!(TestForumModule::forum_sudo().is_none());
-//
-//         // event emitted?!
-//     });
-// }
-//
-// #[test] //TODO - restore forum_sudo
-// fn set_forum_sudo_update() {
-//     let config = default_genesis_config();
-//
-//     build_test_externalities(config).execute_with(|| {
-//         // Ensure that forum sudo is default
-//         assert_eq!(
-//             TestForumModule::forum_sudo(),
-//             Some(default_genesis_config().forum_sudo)
-//         );
-//
-//         let new_forum_sudo_account_id = 780;
-//
-//         // Unset forum sudo
-//         assert_ok!(TestForumModule::set_forum_sudo(
-//             mock_origin(OriginType::Root),
-//             Some(new_forum_sudo_account_id)
-//         ));
-//
-//         // Sudo no longer set
-//         assert_eq!(
-//             TestForumModule::forum_sudo(),
-//             Some(new_forum_sudo_account_id)
-//         );
-//     });
-// }
-
 /*
  * create_category
  * ==============================================================================