MCPcopy Create free account
hub / github.com/Moosync/Moosync / test_update_preferences

Function test_update_preferences

src-tauri/preferences/src/test.rs:211–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209
210#[test]
211fn test_update_preferences() -> Result<()> {
212 let test_dir = setup_test_dir();
213
214 let prefs = PreferenceConfig::new(test_dir.clone())?;
215
216 // Initial data
217 let initial_data = TestConfig {
218 string_value: "initial".to_string(),
219 number_value: 100,
220 boolean_value: false,
221 };
222
223 // Save initial data
224 prefs.save_selective("update_key".to_string(), Some(initial_data))?;
225
226 // Updated data
227 let updated_data = TestConfig {
228 string_value: "updated".to_string(),
229 number_value: 200,
230 boolean_value: true,
231 };
232
233 // Update the data
234 prefs.save_selective("update_key".to_string(), Some(updated_data.clone()))?;
235
236 // Load updated data
237 let loaded_data: TestConfig = prefs.load_selective("update_key".to_string())?;
238
239 // Verify updated data
240 assert_eq!(
241 loaded_data.string_value, "updated",
242 "String value should be updated"
243 );
244 assert_eq!(
245 loaded_data.number_value, 200,
246 "Number value should be updated"
247 );
248 assert!(loaded_data.boolean_value, "Boolean value should be updated");
249
250 cleanup_test_dir(test_dir);
251 Ok(())
252}
253
254#[test]
255fn test_has_key() -> Result<()> {

Callers

nothing calls this directly

Calls 5

setup_test_dirFunction · 0.85
cleanup_test_dirFunction · 0.85
cloneMethod · 0.80
save_selectiveMethod · 0.80
load_selectiveMethod · 0.80

Tested by

no test coverage detected