testcontainers_modules/orientdb/
mod.rs1use std::borrow::Cow;
2
3use testcontainers::{core::WaitFor, Image};
4
5const NAME: &str = "orientdb";
6const TAG: &str = "3.2.19";
7
8#[allow(missing_docs)]
9#[derive(Debug, Default, Clone)]
11pub struct OrientDb {
12 _priv: (),
16}
17
18impl Image for OrientDb {
19 fn name(&self) -> &str {
20 NAME
21 }
22
23 fn tag(&self) -> &str {
24 TAG
25 }
26
27 fn ready_conditions(&self) -> Vec<WaitFor> {
28 vec![WaitFor::message_on_stderr("OrientDB Studio available at")]
29 }
30
31 fn env_vars(
32 &self,
33 ) -> impl IntoIterator<Item = (impl Into<Cow<'_, str>>, impl Into<Cow<'_, str>>)> {
34 [("ORIENTDB_ROOT_PASSWORD", "root")]
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use reqwest::StatusCode;
41 use retry::{delay::Fixed, retry};
42
43 use crate::{orientdb::OrientDb, testcontainers::runners::SyncRunner};
44
45 #[test]
46 fn orientdb_exists_database() {
47 let _ = pretty_env_logger::try_init();
48 let node = OrientDb::default().start().unwrap();
49 let client = reqwest::blocking::Client::new();
50
51 let response = retry(Fixed::from_millis(500).take(5), || {
52 client
53 .get(format!(
54 "http://{}:{}/listDatabases",
55 node.get_host().unwrap(),
56 node.get_host_port_ipv4(2480).unwrap()
57 ))
58 .header("Accept-Encoding", "gzip,deflate")
59 .send()
60 });
61
62 assert_eq!(response.unwrap().status(), StatusCode::OK);
63 }
64}