diff --git a/basedirs/basedirs_test.go b/basedirs/basedirs_test.go index dca41782..fb2394aa 100644 --- a/basedirs/basedirs_test.go +++ b/basedirs/basedirs_test.go @@ -939,6 +939,38 @@ func TestBaseDirs(t *testing.T) { fixSubDirTimes(subdirsA1) So(subdirsA1, ShouldResemble, expectedProjectASubDirs) + + subdirsA3, err := bdr.GroupSubDirs(3, projectA, summary.DGUTAgeAll) + So(err, ShouldBeNil) + + fixSubDirTimes(subdirsA3) + So(subdirsA3, ShouldResemble, []*SubDir{ + { + SubDir: ".", + NumFiles: 2, + SizeFiles: 100, + LastModified: expectedFixedAgeMtime, + FileUsage: map[summary.DirGUTAFileType]uint64{ + summary.DGUTAFileTypeBam: 100, + }, + }, + }) + + subdirsA3, err = bdr.GroupSubDirs(3, projectA, summary.DGUTAgeA3Y) + So(err, ShouldBeNil) + + fixSubDirTimes(subdirsA3) + So(subdirsA3, ShouldResemble, []*SubDir{ + { + SubDir: ".", + NumFiles: 1, + SizeFiles: 40, + LastModified: expectedFixedAgeMtime2, + FileUsage: map[summary.DirGUTAFileType]uint64{ + summary.DGUTAFileTypeBam: 40, + }, + }, + }) }) Convey("getting subdir information for a user-basedir", func() { @@ -1015,6 +1047,38 @@ func TestBaseDirs(t *testing.T) { }, }, }) + + subdirsA3, err := bdr.UserSubDirs(103, projectA, summary.DGUTAgeAll) + So(err, ShouldBeNil) + + fixSubDirTimes(subdirsA3) + So(subdirsA3, ShouldResemble, []*SubDir{ + { + SubDir: ".", + NumFiles: 2, + SizeFiles: 100, + LastModified: expectedFixedAgeMtime, + FileUsage: map[summary.DirGUTAFileType]uint64{ + summary.DGUTAFileTypeBam: 100, + }, + }, + }) + + subdirsA3, err = bdr.UserSubDirs(103, projectA, summary.DGUTAgeA3Y) + So(err, ShouldBeNil) + + fixSubDirTimes(subdirsA3) + So(subdirsA3, ShouldResemble, []*SubDir{ + { + SubDir: ".", + NumFiles: 1, + SizeFiles: 40, + LastModified: expectedFixedAgeMtime2, + FileUsage: map[summary.DirGUTAFileType]uint64{ + summary.DGUTAFileTypeBam: 40, + }, + }, + }) }) joinWithNewLines := func(rows ...string) string { diff --git a/basedirs/db.go b/basedirs/db.go index 3f43494d..f642f8f2 100644 --- a/basedirs/db.go +++ b/basedirs/db.go @@ -444,7 +444,7 @@ func (b *BaseDirs) storeGIDSubDirs(tx *bolt.Tx, gidBase map[uint32]dguta.DCSs) e for gid, dcss := range gidBase { for _, dcs := range dcss { - if err := b.storeSubDirs(bucket, dcs, gid, dguta.Filter{GIDs: []uint32{gid}}); err != nil { + if err := b.storeSubDirs(bucket, dcs, gid, dguta.Filter{GIDs: []uint32{gid}, Age: dcs.Age}); err != nil { return err } } @@ -559,7 +559,7 @@ func (b *BaseDirs) storeUIDSubDirs(tx *bolt.Tx, uids []uint32) error { } for _, dcs := range dcss { - if err := b.storeSubDirs(bucket, dcs, uid, dguta.Filter{UIDs: []uint32{uid}}); err != nil { + if err := b.storeSubDirs(bucket, dcs, uid, dguta.Filter{UIDs: []uint32{uid}, Age: dcs.Age}); err != nil { return err } }