@@ -35,7 +35,7 @@ func TestSimpleDiff(t *testing.T) {
3535 fstest .CreateFile ("/root/.bashrc" , []byte ("PATH=/usr/sbin:/usr/bin" ), 0644 ),
3636 fstest .Remove ("/etc/unexpected" ),
3737 )
38- diff := []testChange {
38+ diff := []TestChange {
3939 Modify ("/etc/hosts" ),
4040 Modify ("/etc/profile" ),
4141 Delete ("/etc/unexpected" ),
@@ -60,7 +60,7 @@ func TestDirectoryReplace(t *testing.T) {
6060 fstest .RemoveAll ("/dir1/f2" ),
6161 fstest .CreateFile ("/dir1/f2" , []byte ("Now file" ), 0666 ),
6262 )
63- diff := []testChange {
63+ diff := []TestChange {
6464 Add ("/dir1/f11" ),
6565 Modify ("/dir1/f2" ),
6666 }
@@ -79,7 +79,7 @@ func TestRemoveDirectoryTree(t *testing.T) {
7979 l2 := fstest .Apply (
8080 fstest .RemoveAll ("/dir1" ),
8181 )
82- diff := []testChange {
82+ diff := []TestChange {
8383 Delete ("/dir1" ),
8484 }
8585
@@ -97,7 +97,7 @@ func TestFileReplace(t *testing.T) {
9797 fstest .CreateDir ("/dir1/dir2" , 0755 ),
9898 fstest .CreateFile ("/dir1/dir2/f1" , []byte ("also a file" ), 0644 ),
9999 )
100- diff := []testChange {
100+ diff := []TestChange {
101101 Modify ("/dir1" ),
102102 Add ("/dir1/dir2" ),
103103 Add ("/dir1/dir2/f1" ),
@@ -136,7 +136,7 @@ func TestUpdateWithSameTime(t *testing.T) {
136136 fstest .CreateFile ("/file-truncated-time-2" , []byte ("2" ), 0644 ),
137137 fstest .Chtime ("/file-truncated-time-2" , tt ),
138138 )
139- diff := []testChange {
139+ diff := []TestChange {
140140 // "/file-same-time" excluded because matching non-zero nanosecond values
141141 Modify ("/file-modified-time" ),
142142 Modify ("/file-truncated-time-1" ),
@@ -148,7 +148,7 @@ func TestUpdateWithSameTime(t *testing.T) {
148148 }
149149}
150150
151- func testDiffWithBase (base , diff fstest.Applier , expected []testChange ) error {
151+ func testDiffWithBase (base , diff fstest.Applier , expected []TestChange ) error {
152152 t1 , err := ioutil .TempDir ("" , "diff-with-base-lower-" )
153153 if err != nil {
154154 return errors .Wrap (err , "failed to create temp dir" )
@@ -188,7 +188,7 @@ func TestBaseDirectoryChanges(t *testing.T) {
188188 fstest .CreateDir ("/root" , 0700 ),
189189 fstest .CreateFile ("/root/.bashrc" , []byte ("PATH=/usr/sbin:/usr/bin" ), 0644 ),
190190 )
191- changes := []testChange {
191+ changes := []TestChange {
192192 Add ("/etc" ),
193193 Add ("/etc/hosts" ),
194194 Add ("/etc/profile" ),
@@ -201,7 +201,7 @@ func TestBaseDirectoryChanges(t *testing.T) {
201201 }
202202}
203203
204- func testDiffWithoutBase (apply fstest.Applier , expected []testChange ) error {
204+ func testDiffWithoutBase (apply fstest.Applier , expected []TestChange ) error {
205205 tmp , err := ioutil .TempDir ("" , "diff-without-base-" )
206206 if err != nil {
207207 return errors .Wrap (err , "failed to create temp dir" )
@@ -220,7 +220,7 @@ func testDiffWithoutBase(apply fstest.Applier, expected []testChange) error {
220220 return checkChanges (tmp , changes , expected )
221221}
222222
223- func checkChanges (root string , changes , expected []testChange ) error {
223+ func checkChanges (root string , changes , expected []TestChange ) error {
224224 if len (changes ) != len (expected ) {
225225 return errors .Errorf ("Unexpected number of changes:\n %s" , diffString (changes , expected ))
226226 }
@@ -253,20 +253,20 @@ func checkChanges(root string, changes, expected []testChange) error {
253253 return nil
254254}
255255
256- type testChange struct {
256+ type TestChange struct {
257257 Kind ChangeKind
258258 Path string
259259 FileInfo os.FileInfo
260260 Source string
261261}
262262
263- func collectChanges (a , b string ) ([]testChange , error ) {
264- changes := []testChange {}
263+ func collectChanges (a , b string ) ([]TestChange , error ) {
264+ changes := []TestChange {}
265265 err := Changes (context .Background (), a , b , func (k ChangeKind , p string , f os.FileInfo , err error ) error {
266266 if err != nil {
267267 return err
268268 }
269- changes = append (changes , testChange {
269+ changes = append (changes , TestChange {
270270 Kind : k ,
271271 Path : p ,
272272 FileInfo : f ,
@@ -281,35 +281,35 @@ func collectChanges(a, b string) ([]testChange, error) {
281281 return changes , nil
282282}
283283
284- func diffString (c1 , c2 []testChange ) string {
284+ func diffString (c1 , c2 []TestChange ) string {
285285 return fmt .Sprintf ("got(%d):\n %s\n expected(%d):\n %s" , len (c1 ), changesString (c1 ), len (c2 ), changesString (c2 ))
286286
287287}
288288
289- func changesString (c []testChange ) string {
289+ func changesString (c []TestChange ) string {
290290 strs := make ([]string , len (c ))
291291 for i := range c {
292292 strs [i ] = fmt .Sprintf ("\t %s\t %s" , c [i ].Kind , c [i ].Path )
293293 }
294294 return strings .Join (strs , "\n " )
295295}
296296
297- func Add (p string ) testChange {
298- return testChange {
297+ func Add (p string ) TestChange {
298+ return TestChange {
299299 Kind : ChangeKindAdd ,
300300 Path : p ,
301301 }
302302}
303303
304- func Delete (p string ) testChange {
305- return testChange {
304+ func Delete (p string ) TestChange {
305+ return TestChange {
306306 Kind : ChangeKindDelete ,
307307 Path : p ,
308308 }
309309}
310310
311- func Modify (p string ) testChange {
312- return testChange {
311+ func Modify (p string ) TestChange {
312+ return TestChange {
313313 Kind : ChangeKindModify ,
314314 Path : p ,
315315 }
0 commit comments