@@ -66,33 +66,48 @@ pub fn is_initialized() -> bool {
6666}
6767
6868#[ cfg( test) ]
69+ #[ cfg( feature = "testing" ) ]
6970mod tests {
7071 use super :: * ;
72+ use crate :: config:: testing:: get_testing_config;
7173 use crate :: config:: PushModelConfigTrait ;
74+ use crate :: config:: DEFAULT_AGENT_DATA_PATH ;
75+
76+ #[ actix_rt:: test]
77+ async fn test_singleton ( ) {
78+ let _mutex = crate :: tpm:: testing:: lock_tests ( ) . await ;
79+ let tmpdir = tempfile:: tempdir ( ) . expect ( "failed to create tmpdir" ) ;
80+ let config = get_testing_config ( tmpdir. path ( ) , None ) ;
81+ let _guard = crate :: config:: TestConfigGuard :: new ( config) ;
7282
73- #[ test]
74- fn test_lazy_initialization ( ) {
7583 // Test that get_config() works with automatic initialization
7684 let config = get_config ( ) ;
7785
7886 // Verify we got a valid configuration
79- assert ! ( !config. uuid( ) . is_empty( ) , "Config should have a valid UUID" ) ;
87+ assert ! (
88+ !config. agent_data_path( ) . is_empty( ) ,
89+ "Config should have a valid agent data path"
90+ ) ;
8091 assert ! (
8192 !config. keylime_dir. is_empty( ) ,
8293 "Config should have a keylime directory"
8394 ) ;
8495
85- // After first access, should be initialized
86- assert ! (
87- is_initialized( ) ,
88- "Config should be initialized after first access"
96+ assert_eq ! ( config. keylime_dir, tmpdir. path( ) . display( ) . to_string( ) ) ;
97+ assert_eq ! (
98+ config. agent_data_path,
99+ tmpdir
100+ . path( )
101+ . join( DEFAULT_AGENT_DATA_PATH )
102+ . display( )
103+ . to_string( )
89104 ) ;
90105
91106 // Subsequent calls should return the same instance
92107 let config2 = get_config ( ) ;
93108 assert_eq ! (
94- config. uuid ( ) ,
95- config2. uuid ( ) ,
109+ config. agent_data_path ( ) ,
110+ config2. agent_data_path ( ) ,
96111 "Should return same config instance"
97112 ) ;
98113 }
0 commit comments