Skip to content

Commit

Permalink
fs: add test for filling auth
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Tang <[email protected]>
  • Loading branch information
sctb512 committed Jul 25, 2023
1 parent b89c5db commit 146b97b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1908,4 +1908,48 @@ mod tests {
assert_eq!(&config.id, "id1");
assert_eq!(config.backend.as_ref().unwrap().backend_type, "localfs");
}

#[test]
fn test_fill_auth() {
let config = r#"
{
"device": {
"id": "test",
"backend": {
"type": "registry",
"config": {
"readahead": false,
"host": "docker.io",
"repo": "library/nginx",
"scheme": "https",
"proxy": {
"fallback": false
},
"timeout": 5,
"connect_timeout": 5,
"retry_limit": 8
}
}
},
"mode": "direct",
"digest_validate": false,
"enable_xattr": true,
"fs_prefetch": {
"enable": true,
"threads_count": 10,
"merging_size": 131072,
"bandwidth_rate": 10485760
}
}"#;

let rafs_config = ConfigV2::from_str(&config).unwrap();
let test_auth = "test_auth".to_string();

let rafs_config = rafs_config.fill_auth(&Some(test_auth.clone()));

let backend = rafs_config.backend.unwrap();
let registry = backend.registry.unwrap();
let auth = registry.auth.unwrap();
assert_eq!(auth, test_auth);
}
}

0 comments on commit 146b97b

Please sign in to comment.