|
| 1 | +// Copyright 2023 Datafuse Labs. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use fastrace::func_name; |
| 16 | + |
| 17 | +use crate::common; |
| 18 | + |
| 19 | +// These bytes are built when a new version in introduced, |
| 20 | +// and are kept for backward compatibility test. |
| 21 | +// |
| 22 | +// ************************************************************* |
| 23 | +// * These messages should never be updated, * |
| 24 | +// * only be added when a new version is added, * |
| 25 | +// * or be removed when an old version is no longer supported. * |
| 26 | +// ************************************************************* |
| 27 | +// |
| 28 | +// The message bytes are built from the output of `test_pb_from_to()` |
| 29 | +#[test] |
| 30 | +fn test_decode_v127_user_iption() -> anyhow::Result<()> { |
| 31 | + let user_option_v127 = vec![ |
| 32 | + 8, 1, 18, 5, 114, 111, 108, 101, 49, 26, 8, 109, 121, 112, 111, 108, 105, 99, 121, 58, 4, |
| 33 | + 109, 121, 119, 103, 160, 6, 127, 168, 6, 24, |
| 34 | + ]; |
| 35 | + |
| 36 | + let want = || { |
| 37 | + databend_common_meta_app::principal::UserOption::default() |
| 38 | + .with_set_flag(databend_common_meta_app::principal::UserOptionFlag::TenantSetting) |
| 39 | + .with_default_role(Some("role1".into())) |
| 40 | + .with_network_policy(Some("mypolicy".to_string())) |
| 41 | + .with_workload_group(Some("mywg".to_string())) |
| 42 | + }; |
| 43 | + |
| 44 | + common::test_pb_from_to(func_name!(), want())?; |
| 45 | + common::test_load_old(func_name!(), user_option_v127.as_slice(), 127, want()) |
| 46 | +} |
0 commit comments