Skip to content

Commit

Permalink
resolve #3
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed Oct 14, 2019
1 parent 6410ddd commit ec69e4d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -8,5 +8,5 @@ os:
- osx

script:
- cargo build --verbose --all
- cargo test --verbose --all
- cargo build --all --all-targets
- cargo test --all
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
# s3mon

[![crates.io](https://img.shields.io/crates/v/s3mon.svg)](https://crates.io/crates/s3mon)
[![CircleCI](https://circleci.com/gh/s3mon/s3mon/tree/master.svg?style=svg)](https://circleci.com/gh/s3mon/s3mon/tree/master)
[![Build Status](https://travis-ci.org/s3mon/s3mon.svg?branch=master)](https://travis-ci.org/s3mon/s3mon)


monitor s3 bucket for missing files
Expand Down
31 changes: 31 additions & 0 deletions src/main.rs
Expand Up @@ -313,4 +313,35 @@ s3mon:
"cubeta,prefix=E error=false exist=false size_mismatch=false",
);
}

#[test]
fn check_object_no_bucket() {
use chrono::prelude::{SecondsFormat, Utc};
use rusoto_core::Region;
use rusoto_mock::{MockCredentialsProvider, MockRequestDispatcher};
use rusoto_s3::S3Client;

let mock = MockRequestDispatcher::with_status(404).with_body(
r#"<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<RequestId>4442587FB7D0A2F9</RequestId>
</Error>"#,
);
let client = Arc::new(s3::S3monS3 {
s3: S3Client::new_with(mock, MockCredentialsProvider, Region::UsEast1),
});
// test finding file & prefix
let file = config::Object {
prefix: "E".to_string(),
age: 30,
size: 512,
};

assert_eq!(
check(client.clone(), "cubeta".to_string(), file),
"cubeta,prefix=E error=true exist=false size_mismatch=false",
);
}
}

0 comments on commit ec69e4d

Please sign in to comment.