@@ -5,8 +5,7 @@ use axum::{
55 routing:: { get, post} ,
66} ;
77use rand:: Rng ;
8- use sandpolis_database:: Database ;
9- use sandpolis_instance:: { ClusterId , InstanceId } ;
8+ use sandpolis_core:: { ClusterId , InstanceId } ;
109use sandpolis_realm:: RealmClusterCert ;
1110use std:: path:: PathBuf ;
1211use tempfile:: TempDir ;
@@ -39,10 +38,13 @@ pub async fn main(config: Configuration, state: InstanceState) -> Result<()> {
3938
4039 info ! ( listener = ?config. server. listen, "Starting server listener" ) ;
4140 axum_server:: bind ( config. server . listen )
42- . acceptor ( sandpolis_realm:: server:: RealmAcceptor :: new (
43- state. instance . clone ( ) ,
44- state. realm . clone ( ) ,
45- ) ?)
41+ . acceptor (
42+ sandpolis_realm:: server:: RealmAcceptor :: new (
43+ state. instance . clone ( ) ,
44+ state. realm . clone ( ) ,
45+ )
46+ . await ?,
47+ )
4648 . serve ( app. with_state ( state) . into_make_service ( ) )
4749 . await
4850 . context ( "binding socket" ) ?;
@@ -55,7 +57,6 @@ pub struct TestServer {
5557 pub port : u16 ,
5658 pub endpoint_cert : PathBuf ,
5759 certs : TempDir ,
58- db : Database ,
5960}
6061
6162/// Run a standalone server instance for testing.
@@ -71,7 +72,7 @@ pub async fn test_server() -> Result<TestServer> {
7172 let mut config = Configuration :: default ( ) ;
7273
7374 // Create temporary database
74- let db = Database :: new_ephemeral ( ) ?;
75+ let database = sandpolis_database :: DatabaseLayer :: new ( config . database . clone ( ) , & crate :: MODELS ) ?;
7576
7677 // Generate temporary certs
7778 let certs = tempdir ( ) ?;
@@ -84,7 +85,7 @@ pub async fn test_server() -> Result<TestServer> {
8485 let port: u16 = rand:: rng ( ) . random_range ( 9000 ..9999 ) ;
8586 config. server . listen = format ! ( "127.0.0.1:{port}" , ) . parse ( ) ?;
8687
87- let state = InstanceState :: new ( config. clone ( ) , db . clone ( ) ) . await ?;
88+ let state = InstanceState :: new ( config. clone ( ) , database ) . await ?;
8889
8990 // Spawn the server
9091 tokio:: spawn ( async move { main ( config, state) . await } ) ;
@@ -93,6 +94,5 @@ pub async fn test_server() -> Result<TestServer> {
9394 port,
9495 endpoint_cert : certs. path ( ) . join ( "client.cert" ) ,
9596 certs,
96- db,
9797 } )
9898}
0 commit comments