1dfe32fa1Soh_ci/* 2dfe32fa1Soh_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3dfe32fa1Soh_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4dfe32fa1Soh_ci * you may not use this file except in compliance with the License. 5dfe32fa1Soh_ci * You may obtain a copy of the License at 6dfe32fa1Soh_ci * 7dfe32fa1Soh_ci * http://www.apache.org/licenses/LICENSE-2.0 8dfe32fa1Soh_ci * 9dfe32fa1Soh_ci * Unless required by applicable law or agreed to in writing, software 10dfe32fa1Soh_ci * distributed under the License is distributed on an "AS IS" BASIS, 11dfe32fa1Soh_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12dfe32fa1Soh_ci * See the License for the specific language governing permissions and 13dfe32fa1Soh_ci * limitations under the License. 14dfe32fa1Soh_ci */ 15dfe32fa1Soh_ci 16dfe32fa1Soh_ciuse crate::common::*; 17dfe32fa1Soh_ciuse asset_sdk::*; 18dfe32fa1Soh_ci 19dfe32fa1Soh_ci#[test] 20dfe32fa1Soh_cifn remove_alias_non_exist() { 21dfe32fa1Soh_ci expect_error_eq(ErrCode::NotFound, remove_by_alias("remove_alias_non_exist".as_bytes()).unwrap_err()); 22dfe32fa1Soh_ci} 23dfe32fa1Soh_ci 24dfe32fa1Soh_ci#[test] 25dfe32fa1Soh_cifn remove_condition_non_exist() { 26dfe32fa1Soh_ci let delete_condition = 27dfe32fa1Soh_ci AssetMap::from([(Tag::DataLabelCritical1, Value::Bytes("remove_condition_non_exist".as_bytes().to_vec()))]); 28dfe32fa1Soh_ci expect_error_eq(ErrCode::NotFound, asset_sdk::Manager::build().unwrap().remove(&delete_condition).unwrap_err()); 29dfe32fa1Soh_ci} 30dfe32fa1Soh_ci 31dfe32fa1Soh_ci#[test] 32dfe32fa1Soh_cifn remove_condition_exist_and_query() { 33dfe32fa1Soh_ci let function_name = function!().as_bytes(); 34dfe32fa1Soh_ci let critical_label = "remove_condition_exist_and_query".as_bytes(); 35dfe32fa1Soh_ci let mut condition = AssetMap::from([ 36dfe32fa1Soh_ci (Tag::Alias, Value::Bytes(function_name.to_owned())), 37dfe32fa1Soh_ci (Tag::Secret, Value::Bytes(function_name.to_owned())), 38dfe32fa1Soh_ci (Tag::DataLabelCritical2, Value::Bytes(critical_label.to_owned())), 39dfe32fa1Soh_ci ]); 40dfe32fa1Soh_ci condition.insert_attr(Tag::Accessibility, Accessibility::DevicePowerOn); 41dfe32fa1Soh_ci asset_sdk::Manager::build().unwrap().add(&condition).unwrap(); 42dfe32fa1Soh_ci condition.remove(&Tag::Alias); 43dfe32fa1Soh_ci condition.remove(&Tag::Secret); 44dfe32fa1Soh_ci asset_sdk::Manager::build().unwrap().remove(&condition).unwrap(); 45dfe32fa1Soh_ci expect_error_eq(ErrCode::NotFound, asset_sdk::Manager::build().unwrap().query(&condition).unwrap_err()); 46dfe32fa1Soh_ci} 47