Skip to content

Commit

Permalink
Add test to ensure Advisories.toml is well-formed
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Feb 26, 2017
1 parent 986c090 commit ec7ca2a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Cargo.lock
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: rust

branches:
only:
- master

rust:
- stable

notifications:
irc: 'irc.mozilla.org#rustsec'
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit ec7ca2a

Please sign in to comment.