-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create
shared_helpers::parse_value_from_args
Signed-off-by: onur-ozkan <work@onurozkan.dev>
- Loading branch information
1 parent
0afc774
commit ee49532
Showing
5 changed files
with
58 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use super::parse_value_from_args; | ||
|
||
#[test] | ||
fn test_parse_value_from_args() { | ||
let args = vec![ | ||
"--stage".into(), | ||
"1".into(), | ||
"--version".into(), | ||
"2".into(), | ||
"--target".into(), | ||
"x86_64-unknown-linux".into(), | ||
]; | ||
|
||
assert_eq!(parse_value_from_args(args.as_slice(), "--stage").unwrap(), "1"); | ||
assert_eq!(parse_value_from_args(args.as_slice(), "--version").unwrap(), "2"); | ||
assert_eq!(parse_value_from_args(args.as_slice(), "--target").unwrap(), "x86_64-unknown-linux"); | ||
assert!(parse_value_from_args(args.as_slice(), "random-key").is_none()); | ||
|
||
let args = vec!["app-name".into(), "--key".into(), "value".into(), "random-value".into()]; | ||
assert_eq!(parse_value_from_args(args.as_slice(), "--key").unwrap(), "value"); | ||
} |