Sebastian Thielrefactor07e0f5e4 years agoHistory
46 lines · 1.1 KB · Rust
RawDownload
use std::{borrow::Cow, convert::TryFrom, error::Error}; use git_config::{    values::{Boolean, Bytes, TrueVariant},    File,}; #[test]fn single_section() -> Result<(), Box<dyn Error>> {    let config = File::try_from("[core]\na=b\nc").unwrap();    let first_value: Bytes = config.value("core", None, "a")?;    let second_value: Boolean = config.value("core", None, "c")?;     assert_eq!(        first_value,        Bytes {            value: Cow::Borrowed(b"b")        }    );    assert_eq!(second_value, Boolean::True(TrueVariant::Implicit));     Ok(())} #[test]fn sections_by_name() {    let config = r#"    [core]        repositoryformatversion = 0        filemode = true        bare = false        logallrefupdates = true    [remote "origin"]        url = git@github.com:Byron/gitoxide.git        fetch = +refs/heads/*:refs/remotes/origin/*    "#;     let config = File::try_from(config).unwrap();    let value = config.value::<Bytes>("remote", Some("origin"), "url").unwrap();    assert_eq!(        value,        Bytes {            value: Cow::Borrowed(b"git@github.com:Byron/gitoxide.git")        }    );}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t