solutions/pallets/template/src/tests.rs

24 lines
621 B
Rust
Raw Normal View History

2020-03-05 16:53:25 +00:00
use crate::{Error, mock::*};
use frame_support::{assert_ok, assert_noop};
#[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.
2020-03-05 16:53:25 +00:00
assert_noop!(
TemplateModule::cause_error(Origin::signed(1)),
Error::<Test>::NoneValue
);
});
}