1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 09:10:40 -05:00

refactor(runtime): remove unneeded Deserialize trait for Permissions struct (#9362)

This commit is contained in:
crowlKats 2021-02-02 18:16:24 +01:00 committed by GitHub
parent 6abf126c2a
commit 9690ce5e87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,7 +68,7 @@ pub struct UnaryPermission<T: Eq + Hash> {
pub denied_list: HashSet<T>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Permissions {
pub read: UnaryPermission<PathBuf>,
pub write: UnaryPermission<PathBuf>,
@ -749,7 +749,6 @@ fn format_host<T: AsRef<str>>(host: &(T, Option<u16>)) -> String {
#[cfg(test)]
mod tests {
use super::*;
use deno_core::serde_json;
// Creates vector of strings, Vec<String>
macro_rules! svec {
@ -1064,54 +1063,6 @@ mod tests {
}
}
#[test]
fn test_deserialize_perms() {
let json_perms = r#"
{
"read": {
"global_state": "Granted",
"granted_list": [],
"denied_list": []
},
"write": {
"global_state": "Granted",
"granted_list": [],
"denied_list": []
},
"net": {
"global_state": "Granted",
"granted_list": [],
"denied_list": []
},
"env": "Granted",
"run": "Granted",
"plugin": "Granted",
"hrtime": "Granted"
}
"#;
let perms0 = Permissions {
read: UnaryPermission {
global_state: PermissionState::Granted,
..Default::default()
},
write: UnaryPermission {
global_state: PermissionState::Granted,
..Default::default()
},
net: UnaryPermission {
global_state: PermissionState::Granted,
..Default::default()
},
env: PermissionState::Granted,
run: PermissionState::Granted,
hrtime: PermissionState::Granted,
plugin: PermissionState::Granted,
};
let deserialized_perms: Permissions =
serde_json::from_str(json_perms).unwrap();
assert_eq!(perms0, deserialized_perms);
}
#[test]
fn test_query() {
let perms1 = Permissions {