From ec7ca2aa88d65d6eb3a9e37dfc27ad981e2b5ceb Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 25 Feb 2017 23:49:53 -0800 Subject: [PATCH] Add test to ensure Advisories.toml is well-formed --- .gitignore | 2 ++ .travis.yml | 11 +++++++++++ Cargo.toml | 11 +++++++++++ src/lib.rs | 25 +++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 Cargo.toml create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a9d37c56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..fc8501a3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: rust + +branches: + only: + - master + +rust: + - stable + +notifications: + irc: 'irc.mozilla.org#rustsec' diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..28f29124 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "rustsec-advisory-db" +version = "0.0.0" +authors = ["Tony Arcieri "] +repository = "https://github.com/rustsec/advisory-db" +documentation = "https://github.com/rustsec/advisory-db" +categories = ["api-bindings", "development-tools"] +keywords = ["rustsec", "security", "advisory", "vulnerability"] + +[dependencies] +rustsec = "^0.2" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..6d537588 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,25 @@ +extern crate rustsec; + +#[cfg(test)] +mod tests { + // Name of the advisory database in the current repo + const ADVISORY_DB_FILE: &'static str = "Advisories.toml"; + + use rustsec::AdvisoryDatabase; + use std::fs::File; + use std::io::Read; + use std::path::Path; + + #[test] + fn advisories_toml_is_well_formed() { + let path = Path::new(ADVISORY_DB_FILE); + + let mut file = File::open(&path).unwrap(); + + let mut toml = String::new(); + file.read_to_string(&mut toml).unwrap(); + + // Ensure Advisories.toml parses + AdvisoryDatabase::from_toml(&toml).unwrap(); + } +}