Skip to content

Commit

Permalink
test: Change database names so that they are unique for every tast.
Browse files Browse the repository at this point in the history
This should prevent rare time dependent error which might have delete database before other process is done using it.
  • Loading branch information
RomanHodulak committed Dec 5, 2021
1 parent c26f784 commit 6b37f99
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ impl<'a, T> CommandWithOptionalInput<'a, T> where T: DatabaseStream {
/// use std::io::Read;
/// let mut client = Client::connect("localhost", 1984, "admin", "admin")?;
///
/// let info = client.create("lambada")?
/// let info = client.create("a45d766")?
/// .with_input(&mut "<Root><Text></Text><Lala></Lala><Papa></Papa></Root>".as_bytes())?;
/// assert!(info.starts_with("Database 'lambada' created"));
/// assert!(info.starts_with("Database 'a45d766' created"));
///
/// let query = client.query(&mut "count(/Root/*)".as_bytes())?;
/// let mut result = String::new();
Expand Down
6 changes: 3 additions & 3 deletions src/client/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::errors::ClientError::CommandFailed;
/// # fn main() -> Result<(), ClientError> {
/// let mut client = Client::connect("localhost", 1984, "admin", "admin")?;
///
/// let info = client.create("lambada")?.without_input()?;
/// assert!(info.starts_with("Database 'lambada' created"));
/// let info = client.create("9f8fe63")?.without_input()?;
/// assert!(info.starts_with("Database '9f8fe63' created"));
/// client.store("blob", &mut &[0u8, 1, 2, 3, 4][..])?;
///
/// let mut result: Vec<u8> = vec![];
Expand All @@ -24,7 +24,7 @@ use crate::errors::ClientError::CommandFailed;
/// let (mut client, info) = response.close()?;
/// assert!(info.starts_with("Query executed in"));
///
/// let (mut client, _) = client.execute("OPEN lambada")?.close()?;
/// let (mut client, _) = client.execute("OPEN 9f8fe63")?.close()?;
/// client.execute("CLOSE")?.close()?;
/// # Ok(())
/// # }
Expand Down
4 changes: 2 additions & 2 deletions tests/command_after_unread_query_succeeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::io::Read;
fn test_command_after_unread_query_succeeds() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?
let info = client.create("dda5457")?
.with_input(&mut "<None><Text></Text><Lala></Lala><Papa></Papa></None>".as_bytes())?;
assert!(info.starts_with("Database 'lambada' created"));
assert!(info.starts_with("Database 'dda5457' created"));

let query = client.query(&mut "count(/None/*)".as_bytes())?;
let response = query.execute()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::io::Read;
fn test_query_creates_xml_on_created_database_with_added_resources() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?.without_input()?;
assert!(info.starts_with("Database 'lambada' created"));
let info = client.create("1cb80e7")?.without_input()?;
assert!(info.starts_with("Database '1cb80e7' created"));

let test_xml = Asset::get("sleeping.xml").unwrap();
let info = client.add("sleeping", &mut test_xml.as_ref())?;
Expand Down
4 changes: 2 additions & 2 deletions tests/query_runs_on_created_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::io::Read;
fn test_query_runs_on_created_database() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?
let info = client.create("918f6e1")?
.with_input(&mut "<None><Text></Text><Lala></Lala><Papa></Papa></None>".as_bytes())?;
assert!(info.starts_with("Database 'lambada' created"));
assert!(info.starts_with("Database '918f6e1' created"));

let query = client.query(&mut "count(/None/*)".as_bytes())?;
let mut result = String::new();
Expand Down
4 changes: 2 additions & 2 deletions tests/query_runs_on_created_database_with_added_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::io::Read;
fn test_query_runs_on_created_database_with_added_resources() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?.without_input()?;
let info = client.create("b34db74")?.without_input()?;

assert!(info.starts_with("Database 'lambada' created"));
assert!(info.starts_with("Database 'b34db74' created"));

let test_xml = Asset::get("sleeping.xml").unwrap();
let info = client.add("sleeping", &mut test_xml.as_ref())?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::io::Read;
fn test_query_runs_on_created_database_with_replaced_resource() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?.without_input()?;
let info = client.create("0076e54")?.without_input()?;

assert!(info.starts_with("Database 'lambada' created"), "Actual info: {}", info);
assert!(info.starts_with("Database '0076e54' created"), "Actual info: {}", info);

let test_xml = Asset::get("powder.xml").unwrap();
let info = client.add("sleeping", &mut test_xml.as_ref())?;
Expand Down
4 changes: 2 additions & 2 deletions tests/storing_and_retrieving_binary_file_succeeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::io::Read;
fn test_storing_and_retrieving_binary_file_succeeds() -> Result<(), ClientError> {
let mut client = Client::connect("localhost", 1984, "admin", "admin")?;

let info = client.create("lambada")?.without_input()?;
assert!(info.starts_with("Database 'lambada' created"));
let info = client.create("9f83d0a")?.without_input()?;
assert!(info.starts_with("Database '9f83d0a' created"));

let expected_result = [6u8, 1, 0xFF, 3, 4, 0u8, 6, 5];
client.store("blob", &mut &expected_result[..])?;
Expand Down

0 comments on commit 6b37f99

Please sign in to comment.