2021-07-20 12:44:58 +00:00
|
|
|
use crate::{mock::*, Error};
|
|
|
|
use frame_support::{assert_noop, assert_ok};
|
2020-03-05 16:53:25 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn it_works_for_default_value() {
|
|
|
|
new_test_ext().execute_with(|| {
|
2020-07-25 12:35:30 +00:00
|
|
|
// Dispatch a signed extrinsic.
|
2020-03-05 16:53:25 +00:00
|
|
|
assert_ok!(TemplateModule::do_something(Origin::signed(1), 42));
|
2020-07-25 12:35:30 +00:00
|
|
|
// Read pallet storage and assert an expected result.
|
2020-03-05 16:53:25 +00:00
|
|
|
assert_eq!(TemplateModule::something(), Some(42));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn correct_error_for_none_value() {
|
|
|
|
new_test_ext().execute_with(|| {
|
2020-07-25 12:35:30 +00:00
|
|
|
// Ensure the expected error is thrown when no value is present.
|
2021-07-20 12:44:58 +00:00
|
|
|
assert_noop!(TemplateModule::cause_error(Origin::signed(1)), Error::<Test>::NoneValue);
|
2020-03-05 16:53:25 +00:00
|
|
|
});
|
|
|
|
}
|