1 package lfs_test // avoid import cycle
8 "github.com/git-lfs/git-lfs/fs"
9 "github.com/git-lfs/git-lfs/lfs"
10 test "github.com/git-lfs/git-lfs/t/cmd/util"
11 "github.com/stretchr/testify/assert"
14 func TestAllCurrentObjectsNone(t *testing.T) {
15 repo := test.NewRepo(t)
23 repo.Filesystem().EachObject(func(obj fs.Object) error {
25 t.Logf("Found: %+v", obj)
29 t.Error("Should be no objects")
33 func TestAllCurrentObjectsSome(t *testing.T) {
34 repo := test.NewRepo(t)
41 // We're not testing commits here, just storage, so just create a single
42 // commit input with lots of files to generate many oids
44 files := make([]*test.FileInput, 0, numFiles)
45 for i := 0; i < numFiles; i++ {
46 // Must be >=16 bytes for each file to be unique
47 files = append(files, &test.FileInput{Filename: fmt.Sprintf("file%d.txt", i), Size: 30})
50 inputs := []*test.CommitInput{
54 outputs := repo.AddCommits(inputs)
56 expected := make([]*lfs.Pointer, 0, numFiles)
57 for _, f := range outputs[0].Files {
58 expected = append(expected, f)
61 actual := make([]*lfs.Pointer, 0)
62 repo.Filesystem().EachObject(func(obj fs.Object) error {
63 actual = append(actual, lfs.NewPointer(obj.Oid, obj.Size, nil))
67 // sort to ensure comparison is equal
68 sort.Sort(test.PointersByOid(expected))
69 sort.Sort(test.PointersByOid(actual))
70 assert.Equal(t, expected, actual, "Oids from disk should be the same as in commits")