Skip to content

Commit

Permalink
test: Added test on repos
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 23, 2018
1 parent 49f4570 commit 12411e1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,10 @@ pub struct RepoReference {
pub name: String,
/// The optional prefix path to apply to source code when pairing it
/// up with files in the repository.
#[serde(skip_serializing_if = "Option::is_none")]
pub prefix: Option<String>,
/// The optional current revision of the local repository.
#[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<String>,
}

Expand Down
57 changes: 57 additions & 0 deletions tests/test_protocol_v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ extern crate serde;
extern crate serde_json;
extern crate uuid;

use std::collections::HashMap;

use sentry_types::protocol::v7;

fn reserialize(event: &v7::Event) -> v7::Event {
Expand Down Expand Up @@ -125,6 +127,61 @@ fn test_logentry_basics() {
);
}

#[test]
fn test_modules() {
let event = v7::Event {
modules: {
let mut m = HashMap::new();
m.insert("System".into(), "1.0.0".into());
m
},
..Default::default()
};
assert_eq!(
serde_json::to_string(&event).unwrap(),
"{\"modules\":{\"System\":\"1.0.0\"}}"
);
}

#[test]
fn test_repos() {
let event = v7::Event {
repos: {
let mut m = HashMap::new();
m.insert("/raven".into(), v7::RepoReference {
name: "github/raven".into(),
prefix: Some("/".into()),
revision: Some("49f45700b5fe606c1bcd9bf0205ecbb83db17f52".into()),
});
m
},
..Default::default()
};

assert_eq!(
serde_json::to_string(&event).unwrap(),
"{\"repos\":{\"/raven\":{\"name\":\"github/raven\",\"prefix\":\"/\",\"revision\":\"49f45700b5fe606c1bcd9bf0205ecbb83db17f52\"}}}"
);

let event = v7::Event {
repos: {
let mut m = HashMap::new();
m.insert("/raven".into(), v7::RepoReference {
name: "github/raven".into(),
prefix: None,
revision: None,
});
m
},
..Default::default()
};

assert_eq!(
serde_json::to_string(&event).unwrap(),
"{\"repos\":{\"/raven\":{\"name\":\"github/raven\"}}}"
);
}

#[test]
fn test_canonical_exception() {
let mut event: v7::Event = Default::default();
Expand Down

0 comments on commit 12411e1

Please sign in to comment.