@@ -120,6 +120,29 @@ func TestWriteFiles(t *testing.T) {
120
120
},
121
121
checkState : checkOnSuccess ,
122
122
},
123
+ {
124
+ name : "target directory is empty" ,
125
+ newFS : newRealFS ,
126
+ directoryData : map [string ][]byte {},
127
+ objectData : map [string ][]byte {
128
+ "tls.crt" : []byte ("TLS cert" ),
129
+ "tls.key" : []byte ("TLS key" ),
130
+ },
131
+ checkState : checkOnSuccess ,
132
+ },
133
+ {
134
+ name : "target directory already synchronized" ,
135
+ newFS : newRealFS ,
136
+ directoryData : map [string ][]byte {
137
+ "tls.crt" : []byte ("TLS cert" ),
138
+ "tls.key" : []byte ("TLS key" ),
139
+ },
140
+ objectData : map [string ][]byte {
141
+ "tls.crt" : []byte ("TLS cert" ),
142
+ "tls.key" : []byte ("TLS key" ),
143
+ },
144
+ checkState : checkOnSuccess ,
145
+ },
123
146
{
124
147
name : "change file contents preserving the filenames" ,
125
148
newFS : newRealFS ,
@@ -198,6 +221,43 @@ func TestWriteFiles(t *testing.T) {
198
221
},
199
222
checkState : checkOnSuccess ,
200
223
},
224
+ {
225
+ name : "add new files" ,
226
+ newFS : newRealFS ,
227
+ directoryData : map [string ][]byte {
228
+ "tls.crt" : []byte ("TLS cert" ),
229
+ "tls.key" : []byte ("TLS key" ),
230
+ },
231
+ objectData : map [string ][]byte {
232
+ "tls.crt" : []byte ("TLS cert" ),
233
+ "tls.key" : []byte ("TLS key" ),
234
+ "another_tls.crt" : []byte ("another TLS cert" ),
235
+ "another_tls.key" : []byte ("another TLS key" ),
236
+ },
237
+ checkState : checkOnSuccess ,
238
+ },
239
+ {
240
+ name : "delete a single file" ,
241
+ newFS : newRealFS ,
242
+ directoryData : map [string ][]byte {
243
+ "1.txt" : []byte ("1" ),
244
+ "2.txt" : []byte ("2" ),
245
+ },
246
+ objectData : map [string ][]byte {
247
+ "1.txt" : []byte ("1" ),
248
+ },
249
+ checkState : checkOnSuccess ,
250
+ },
251
+ {
252
+ name : "delete all files" ,
253
+ newFS : newRealFS ,
254
+ directoryData : map [string ][]byte {
255
+ "1.txt" : []byte ("1" ),
256
+ "2.txt" : []byte ("2" ),
257
+ },
258
+ objectData : map [string ][]byte {},
259
+ checkState : checkOnSuccess ,
260
+ },
201
261
errorTestCase ("directory unchanged on failed to create object directory" , func () * fileSystem {
202
262
fs := newRealFS ()
203
263
fs .MkdirAll = func (path string , perm os.FileMode ) error {
0 commit comments