fix: add test about user_info_v3
@@ -32,7 +32,7 @@ fn s(ss: impl ToString) -> String {
fn test_user_info() -> UserInfo {
let option = mt::UserOption::default()
.with_set_flag(mt::UserOptionFlag::TenantSetting)
- .with_default_role(None);
+ .with_default_role(Some("role1".into()));
mt::UserInfo {
name: "test_user".to_string(),
@@ -186,16 +186,27 @@ fn test_load_old_user() -> anyhow::Result<()> {
6, 1, 160, 6, 1, 42, 12, 8, 10, 16, 128, 80, 24, 128, 160, 1, 160, 6, 1, 50, 5, 8, 1,
160, 6, 1, 160, 6, 1,
];
-
let p: pb::UserInfo =
common_protos::prost::Message::decode(user_info_v1.as_slice()).map_err(print_err)?;
-
let got = mt::UserInfo::from_pb(p).map_err(print_err)?;
-
println!("got: {:?}", got);
+ assert_eq!(got.name, "test_user".to_string());
+ assert_eq!(got.option.default_role().clone(), None);
+ }
+ {
+ let user_info_v3: Vec<u8> = vec![
+ 10, 9, 116, 101, 115, 116, 95, 117, 115, 101, 114, 18, 9, 108, 111, 99, 97, 108, 104,
+ 111, 115, 116, 26, 25, 18, 17, 10, 13, 116, 101, 115, 116, 95, 112, 97, 115, 115, 119,
+ 111, 114, 100, 16, 1, 160, 6, 3, 168, 6, 1, 34, 26, 10, 18, 10, 8, 10, 0, 160, 6, 3,
+ 168, 6, 1, 16, 2, 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1, 42, 15, 8, 10, 16, 128,
+ 80, 24, 128, 160, 1, 160, 6, 3, 168, 6, 1, 50, 15, 8, 1, 18, 5, 114, 111, 108, 101, 49,
+ 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1,
+ ];
+ let p: pb::UserInfo =
+ common_protos::prost::Message::decode(user_info_v3.as_slice()).map_err(print_err)?;
+ let got = mt::UserInfo::from_pb(p).map_err(print_err)?;
let want = test_user_info();
-
assert_eq!(want, got);
}
