Add test to ensure Advisories.toml is well-formed

This commit is contained in:
Tony Arcieri
2017-02-25 23:49:53 -08:00
parent 986c090c06
commit ec7ca2aa88
4 changed files with 49 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
target
Cargo.lock

11
.travis.yml Normal file
View File

@@ -0,0 +1,11 @@
language: rust
branches:
only:
- master
rust:
- stable
notifications:
irc: 'irc.mozilla.org#rustsec'

11
Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
name = "rustsec-advisory-db"
version = "0.0.0"
authors = ["Tony Arcieri <bascule@gmail.com>"]
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"

25
src/lib.rs Normal file
View File

@@ -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();
}
}