Skip to content

Commit

Permalink
Merge pull request #26 from Bond-009/manjaro
Browse files Browse the repository at this point in the history
Add Manjaro
  • Loading branch information
Jan Schulte committed Sep 16, 2018
2 parents 51cb7e1 + a4fddb8 commit ce82ff4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -46,6 +46,7 @@ Right now, the following operating system types can be returned:
- Ubuntu
- Debian
- Arch
- Manjaro

If you need support for more OS types, I am looking forward to your Pull Request.

Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Expand Up @@ -19,6 +19,7 @@ pub enum OSType {
Ubuntu,
Debian,
Arch,
Manjaro,
CentOS,
OpenSUSE
}
Expand Down Expand Up @@ -81,6 +82,11 @@ fn lsb_release() -> OSInformation {
os_type: OSType::Arch,
version: release.version.unwrap_or(default_version())
}
} else if release.distro == Some("ManjaroLinux".to_string()) {
OSInformation {
os_type: OSType::Manjaro,
version: release.version.unwrap_or(default_version())
}
}
else if release.distro == Some("CentOS".to_string()){
OSInformation {
Expand Down
22 changes: 22 additions & 0 deletions tests/lsb_release_test.rs
Expand Up @@ -23,6 +23,16 @@ Codename: n/a
".to_string()
}

fn manjaro_file() -> String {
"
LSB Version: n/a
Distributor ID: ManjaroLinux
Description: Manjaro Linux
Release: 17.1.7
Codename: Hakoila
".to_string()
}

fn opensuse_tumbleweed_file() -> String {
"
LSB Version: n/a
Expand Down Expand Up @@ -57,6 +67,18 @@ pub fn test_parses_arch_lsb_version() {
assert_eq!(parse_results.version, Some("rolling".to_string()));
}

#[test]
pub fn test_parses_manjaro_lsb_distro() {
let parse_results = lsb_release::parse(manjaro_file());
assert_eq!(parse_results.distro, Some("ManjaroLinux".to_string()));
}

#[test]
pub fn test_parses_manjaro_lsb_version() {
let parse_results = lsb_release::parse(manjaro_file());
assert_eq!(parse_results.version, Some("17.1.7".to_string()));
}

#[test]
pub fn test_parses_opensuse_lsb_distro() {
let parse_results = lsb_release::parse(opensuse_tumbleweed_file());
Expand Down

0 comments on commit ce82ff4

Please sign in to comment.