MCPcopy Create free account
hub / github.com/hashintel/hash / new_with_settings

Method new_with_settings

tests/graph/integration/postgres/lib.rs:162–202  ·  view source on GitHub ↗
(settings: PostgresStoreSettings)

Source from the content-addressed store, hash-verified

160 }
161
162 pub async fn new_with_settings(settings: PostgresStoreSettings) -> Self {
163 load_env(Environment::Test);
164 init_logging();
165
166 let user = std::env::var("HASH_GRAPH_PG_USER").unwrap_or_else(|_| "graph".to_owned());
167 let password =
168 std::env::var("HASH_GRAPH_PG_PASSWORD").unwrap_or_else(|_| "graph".to_owned());
169 let host = std::env::var("HASH_GRAPH_PG_HOST").unwrap_or_else(|_| "localhost".to_owned());
170 let port =
171 std::env::var("HASH_GRAPH_PG_PORT").map_or(5432, |port| port.parse::<u16>().unwrap());
172 let database =
173 std::env::var("HASH_GRAPH_PG_DATABASE").unwrap_or_else(|_| "graph".to_owned());
174
175 let connection_info = DatabaseConnectionInfo::new(
176 DatabaseType::Postgres,
177 user,
178 password,
179 host,
180 port,
181 database,
182 );
183
184 let pool = PostgresStorePool::new(
185 &connection_info,
186 &DatabasePoolConfig::default(),
187 NoTls,
188 settings,
189 )
190 .await
191 .expect("could not connect to database");
192
193 let connection = pool
194 .acquire_owned(None)
195 .await
196 .expect("could not acquire a database connection");
197
198 Self {
199 _pool: pool,
200 connection,
201 }
202 }
203}
204
205impl DatabaseTestWrapper {

Callers

nothing calls this directly

Calls 7

load_envFunction · 0.85
unwrapMethod · 0.80
init_loggingFunction · 0.70
defaultFunction · 0.50
to_ownedMethod · 0.45
expectMethod · 0.45
acquire_ownedMethod · 0.45

Tested by

no test coverage detected