Skip to content

Commit

Permalink
Make a copy of the test database for GET/HEAD HTTP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Aug 20, 2020
1 parent fa2b2aa commit d3604d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/config/get_head.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
path = "tests/data/001.db"
path = "/tmp/stored/get_head_tests.db"

[http]
address = "127.0.0.1:9001"
10 changes: 10 additions & 0 deletions tests/http/get_head.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
//! Tests for GET and HEAD requests.

use std::sync::Once;

use http::header::{CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, LAST_MODIFIED};
use http::status::StatusCode;
use log::LevelFilter;

use crate::util::copy_database;
use crate::util::http::{assert_response, body, header, request};

const DB_PORT: u16 = 9001;
const DB_PATH: &str = "/tmp/stored/get_head_tests.db";
const CONF_PATH: &str = "tests/config/get_head.toml";
const FILTER: LevelFilter = LevelFilter::Warn;

static CP_DB: Once = Once::new();

start_stored_fn!(&[CONF_PATH], &[], FILTER);

/// Make a GET and HEAD request and check the response.
Expand All @@ -21,6 +27,10 @@ macro_rules! test {
expected: $want_status: expr, $want_body: expr,
$($header_name: ident => $header_value: expr),*,
) => {{
CP_DB.call_once(|| {
copy_database("tests/data/001.db", DB_PATH);
});

let _p = start_stored();

request!(
Expand Down

0 comments on commit d3604d0

Please sign in to comment.