@@ -127,7 +127,7 @@ func TestWriteFiles(t *testing.T) {
127
127
checkState : checkOnSuccess ,
128
128
},
129
129
{
130
- name : "update target directory change file content " ,
130
+ name : "change file contents preserving the filenames " ,
131
131
newFS : newRealFS ,
132
132
directoryData : map [string ][]byte {
133
133
"tls.crt" : []byte ("TLS cert" ),
@@ -140,7 +140,20 @@ func TestWriteFiles(t *testing.T) {
140
140
checkState : checkOnSuccess ,
141
141
},
142
142
{
143
- name : "update target directory change filenames" ,
143
+ name : "change filenames preserving the file contents" ,
144
+ newFS : newRealFS ,
145
+ directoryData : map [string ][]byte {
146
+ "tls.crt" : []byte ("TLS cert" ),
147
+ "tls.key" : []byte ("TLS key" ),
148
+ },
149
+ objectData : map [string ][]byte {
150
+ "api.crt" : []byte ("TLS cert" ),
151
+ "api.key" : []byte ("TLS key" ),
152
+ },
153
+ checkState : checkOnSuccess ,
154
+ },
155
+ {
156
+ name : "change filenames and file contents" ,
144
157
newFS : newRealFS ,
145
158
directoryData : map [string ][]byte {
146
159
"tls.crt" : []byte ("TLS cert" ),
@@ -152,6 +165,45 @@ func TestWriteFiles(t *testing.T) {
152
165
},
153
166
checkState : checkOnSuccess ,
154
167
},
168
+ {
169
+ name : "replace a single file content" ,
170
+ newFS : newRealFS ,
171
+ directoryData : map [string ][]byte {
172
+ "1.txt" : []byte ("1" ),
173
+ "2.txt" : []byte ("2" ),
174
+ },
175
+ objectData : map [string ][]byte {
176
+ "1.txt" : []byte ("1" ),
177
+ "2.txt" : []byte ("3" ),
178
+ },
179
+ checkState : checkOnSuccess ,
180
+ },
181
+ {
182
+ name : "replace a single file" ,
183
+ newFS : newRealFS ,
184
+ directoryData : map [string ][]byte {
185
+ "1.txt" : []byte ("1" ),
186
+ "2.txt" : []byte ("2" ),
187
+ },
188
+ objectData : map [string ][]byte {
189
+ "1.txt" : []byte ("1" ),
190
+ "3.txt" : []byte ("3" ),
191
+ },
192
+ checkState : checkOnSuccess ,
193
+ },
194
+ {
195
+ name : "rename a single file" ,
196
+ newFS : newRealFS ,
197
+ directoryData : map [string ][]byte {
198
+ "1.txt" : []byte ("1" ),
199
+ "2.txt" : []byte ("2" ),
200
+ },
201
+ objectData : map [string ][]byte {
202
+ "1.txt" : []byte ("1" ),
203
+ "3.txt" : []byte ("2" ),
204
+ },
205
+ checkState : checkOnSuccess ,
206
+ },
155
207
errorTestCase ("directory unchanged on failed to create object directory" , func () * fileSystem {
156
208
fs := newRealFS ()
157
209
fs .MkdirAll = func (path string , perm os.FileMode ) error {
0 commit comments