@@ -85,13 +85,15 @@ mod tests {
8585
8686 #[ test]
8787 fn save_settings_should_preserve_existing_webdav_when_payload_omits_it ( ) {
88- let mut existing = AppSettings :: default ( ) ;
89- existing. webdav_sync = Some ( WebDavSyncSettings {
90- base_url : "https://dav.example.com" . to_string ( ) ,
91- username : "alice" . to_string ( ) ,
92- password : "secret" . to_string ( ) ,
93- ..WebDavSyncSettings :: default ( )
94- } ) ;
88+ let existing = AppSettings {
89+ webdav_sync : Some ( WebDavSyncSettings {
90+ base_url : "https://dav.example.com" . to_string ( ) ,
91+ username : "alice" . to_string ( ) ,
92+ password : "secret" . to_string ( ) ,
93+ ..WebDavSyncSettings :: default ( )
94+ } ) ,
95+ ..Default :: default ( )
96+ } ;
9597
9698 let incoming = AppSettings :: default ( ) ;
9799 let merged = merge_settings_for_save ( incoming, & existing) ;
@@ -105,21 +107,25 @@ mod tests {
105107
106108 #[ test]
107109 fn save_settings_should_keep_incoming_webdav_when_present ( ) {
108- let mut existing = AppSettings :: default ( ) ;
109- existing. webdav_sync = Some ( WebDavSyncSettings {
110- base_url : "https://dav.old.example.com" . to_string ( ) ,
111- username : "old" . to_string ( ) ,
112- password : "old-pass" . to_string ( ) ,
113- ..WebDavSyncSettings :: default ( )
114- } ) ;
115-
116- let mut incoming = AppSettings :: default ( ) ;
117- incoming. webdav_sync = Some ( WebDavSyncSettings {
118- base_url : "https://dav.new.example.com" . to_string ( ) ,
119- username : "new" . to_string ( ) ,
120- password : "new-pass" . to_string ( ) ,
121- ..WebDavSyncSettings :: default ( )
122- } ) ;
110+ let existing = AppSettings {
111+ webdav_sync : Some ( WebDavSyncSettings {
112+ base_url : "https://dav.old.example.com" . to_string ( ) ,
113+ username : "old" . to_string ( ) ,
114+ password : "old-pass" . to_string ( ) ,
115+ ..WebDavSyncSettings :: default ( )
116+ } ) ,
117+ ..Default :: default ( )
118+ } ;
119+
120+ let incoming = AppSettings {
121+ webdav_sync : Some ( WebDavSyncSettings {
122+ base_url : "https://dav.new.example.com" . to_string ( ) ,
123+ username : "new" . to_string ( ) ,
124+ password : "new-pass" . to_string ( ) ,
125+ ..WebDavSyncSettings :: default ( )
126+ } ) ,
127+ ..Default :: default ( )
128+ } ;
123129
124130 let merged = merge_settings_for_save ( incoming, & existing) ;
125131
@@ -135,22 +141,26 @@ mod tests {
135141 /// must NOT overwrite the existing one.
136142 #[ test]
137143 fn save_settings_should_preserve_password_when_incoming_has_empty_password ( ) {
138- let mut existing = AppSettings :: default ( ) ;
139- existing. webdav_sync = Some ( WebDavSyncSettings {
140- base_url : "https://dav.example.com" . to_string ( ) ,
141- username : "alice" . to_string ( ) ,
142- password : "secret" . to_string ( ) ,
143- ..WebDavSyncSettings :: default ( )
144- } ) ;
144+ let existing = AppSettings {
145+ webdav_sync : Some ( WebDavSyncSettings {
146+ base_url : "https://dav.example.com" . to_string ( ) ,
147+ username : "alice" . to_string ( ) ,
148+ password : "secret" . to_string ( ) ,
149+ ..WebDavSyncSettings :: default ( )
150+ } ) ,
151+ ..Default :: default ( )
152+ } ;
145153
146154 // Simulate frontend sending settings with cleared password
147- let mut incoming = AppSettings :: default ( ) ;
148- incoming. webdav_sync = Some ( WebDavSyncSettings {
149- base_url : "https://dav.example.com" . to_string ( ) ,
150- username : "alice" . to_string ( ) ,
151- password : "" . to_string ( ) ,
152- ..WebDavSyncSettings :: default ( )
153- } ) ;
155+ let incoming = AppSettings {
156+ webdav_sync : Some ( WebDavSyncSettings {
157+ base_url : "https://dav.example.com" . to_string ( ) ,
158+ username : "alice" . to_string ( ) ,
159+ password : "" . to_string ( ) ,
160+ ..WebDavSyncSettings :: default ( )
161+ } ) ,
162+ ..Default :: default ( )
163+ } ;
154164
155165 let merged = merge_settings_for_save ( incoming, & existing) ;
156166
@@ -165,21 +175,25 @@ mod tests {
165175 /// work without panicking and keep the empty state.
166176 #[ test]
167177 fn save_settings_should_handle_both_empty_passwords ( ) {
168- let mut existing = AppSettings :: default ( ) ;
169- existing. webdav_sync = Some ( WebDavSyncSettings {
170- base_url : "https://dav.example.com" . to_string ( ) ,
171- username : "alice" . to_string ( ) ,
172- password : "" . to_string ( ) ,
173- ..WebDavSyncSettings :: default ( )
174- } ) ;
175-
176- let mut incoming = AppSettings :: default ( ) ;
177- incoming. webdav_sync = Some ( WebDavSyncSettings {
178- base_url : "https://dav.example.com" . to_string ( ) ,
179- username : "alice" . to_string ( ) ,
180- password : "" . to_string ( ) ,
181- ..WebDavSyncSettings :: default ( )
182- } ) ;
178+ let existing = AppSettings {
179+ webdav_sync : Some ( WebDavSyncSettings {
180+ base_url : "https://dav.example.com" . to_string ( ) ,
181+ username : "alice" . to_string ( ) ,
182+ password : "" . to_string ( ) ,
183+ ..WebDavSyncSettings :: default ( )
184+ } ) ,
185+ ..Default :: default ( )
186+ } ;
187+
188+ let incoming = AppSettings {
189+ webdav_sync : Some ( WebDavSyncSettings {
190+ base_url : "https://dav.example.com" . to_string ( ) ,
191+ username : "alice" . to_string ( ) ,
192+ password : "" . to_string ( ) ,
193+ ..WebDavSyncSettings :: default ( )
194+ } ) ,
195+ ..Default :: default ( )
196+ } ;
183197
184198 let merged = merge_settings_for_save ( incoming, & existing) ;
185199
0 commit comments