Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-09 09:01:22 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-11 16:07:33 +0300
commita751b34ff3e2e88e0d6007215b7d648f63da959f (patch)
treefd5c725084c1d0010df070ede2f1a8dd2da0bd28
parent8f1a982ce59922d2ceaacbe18a000e68d4511379 (diff)
gitpipe: Refactor Revision tests to not use seeded repos
Refactor the Revision tests to not use seeded repositories with hardcoded object IDs. Instead, the tests are changed such that they generate test data at runtime so that we can easily support different object hashes.
-rw-r--r--internal/git/gitpipe/catfile_info_test.go1
-rw-r--r--internal/git/gitpipe/revision_test.go315
2 files changed, 155 insertions, 161 deletions
diff --git a/internal/git/gitpipe/catfile_info_test.go b/internal/git/gitpipe/catfile_info_test.go
index 76164cd3c..f4513361a 100644
--- a/internal/git/gitpipe/catfile_info_test.go
+++ b/internal/git/gitpipe/catfile_info_test.go
@@ -22,7 +22,6 @@ const (
lfsPointer1 = "0c304a93cb8430108629bbbcaa27db3343299bc0"
lfsPointer2 = "f78df813119a79bfbe0442ab92540a61d3ab7ff3"
lfsPointer3 = "bab31d249f78fba464d1b75799aad496cc07fa3b"
- lfsPointer4 = "125fcc9f6e33175cb278b9b2809154d2535fe19f"
)
func TestCatfileInfo(t *testing.T) {
diff --git a/internal/git/gitpipe/revision_test.go b/internal/git/gitpipe/revision_test.go
index 7e740c247..0320cce70 100644
--- a/internal/git/gitpipe/revision_test.go
+++ b/internal/git/gitpipe/revision_test.go
@@ -3,6 +3,7 @@
package gitpipe
import (
+ "bytes"
"context"
"errors"
"testing"
@@ -22,12 +23,58 @@ func TestRevlist(t *testing.T) {
ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
- repoProto, _ := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
+ repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
})
repo := localrepo.NewTestRepo(t, cfg, repoProto)
+ blobA := gittest.WriteBlob(t, cfg, repoPath, bytes.Repeat([]byte("a"), 133))
+ blobB := gittest.WriteBlob(t, cfg, repoPath, bytes.Repeat([]byte("b"), 127))
+ blobC := gittest.WriteBlob(t, cfg, repoPath, bytes.Repeat([]byte("c"), 127))
+ blobD := gittest.WriteBlob(t, cfg, repoPath, bytes.Repeat([]byte("d"), 129))
+
+ blob := gittest.WriteBlob(t, cfg, repoPath, []byte("a"))
+ subblob := gittest.WriteBlob(t, cfg, repoPath, []byte("larger blob"))
+
+ treeA := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
+ {Path: "branch-test.txt", Mode: "100644", OID: blob},
+ })
+ commitA := gittest.WriteCommit(t, cfg, repoPath,
+ gittest.WithTree(treeA),
+ gittest.WithCommitterDate(time.Date(2000, 1, 1, 1, 1, 1, 1, time.UTC)),
+ )
+
+ subtree := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
+ {Path: "subblob", Mode: "100644", OID: subblob},
+ })
+ treeB := gittest.WriteTree(t, cfg, repoPath, []gittest.TreeEntry{
+ {Path: "branch-test.txt", Mode: "100644", OID: blob},
+ {Path: "subtree", Mode: "040000", OID: subtree},
+ })
+ commitB := gittest.WriteCommit(t, cfg, repoPath,
+ gittest.WithParents(commitA),
+ gittest.WithTree(treeB),
+ gittest.WithCommitterDate(time.Date(1999, 1, 1, 1, 1, 1, 1, time.UTC)),
+ gittest.WithAuthorName("custom author"),
+ )
+
+ commitBParent := gittest.WriteCommit(t, cfg, repoPath,
+ gittest.WithParents(commitB),
+ gittest.WithTree(treeB),
+ gittest.WithCommitterDate(time.Date(2001, 1, 1, 1, 1, 1, 1, time.UTC)),
+ )
+ commitAParent := gittest.WriteCommit(t, cfg, repoPath,
+ gittest.WithParents(commitA),
+ gittest.WithTree(treeA),
+ gittest.WithCommitterDate(time.Date(2001, 1, 1, 1, 1, 1, 1, time.UTC)),
+ )
+
+ mergeCommit := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(commitAParent, commitBParent))
+
+ tag := gittest.WriteTag(t, cfg, repoPath, "v1.0.0", mergeCommit.Revision(), gittest.WriteTagConfig{
+ Message: "annotated tag",
+ })
+
for _, tc := range []struct {
desc string
revisions []string
@@ -38,150 +85,146 @@ func TestRevlist(t *testing.T) {
{
desc: "single blob",
revisions: []string{
- lfsPointer1,
+ blobA.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: lfsPointer1},
+ {OID: blobA},
},
},
{
desc: "multiple blobs",
revisions: []string{
- lfsPointer1,
- lfsPointer2,
- lfsPointer3,
- lfsPointer4,
+ blobA.String(),
+ blobB.String(),
+ blobC.String(),
+ blobD.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: lfsPointer1},
- {OID: lfsPointer2},
- {OID: lfsPointer3},
- {OID: lfsPointer4},
+ {OID: blobA},
+ {OID: blobB},
+ {OID: blobC},
+ {OID: blobD},
},
},
{
desc: "multiple blobs without objects",
revisions: []string{
- lfsPointer1,
- lfsPointer2,
- lfsPointer3,
- lfsPointer4,
+ blobA.String(),
+ blobB.String(),
+ blobC.String(),
+ blobD.String(),
},
expectedResults: nil,
},
{
desc: "duplicated blob prints blob once only",
revisions: []string{
- lfsPointer1,
- lfsPointer1,
+ blobA.String(),
+ blobA.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: lfsPointer1},
+ {OID: blobA},
},
},
{
desc: "tree results in object names",
revisions: []string{
- "b95c0fad32f4361845f91d9ce4c1721b52b82793",
+ treeA.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: "b95c0fad32f4361845f91d9ce4c1721b52b82793"},
- {OID: "93e123ac8a3e6a0b600953d7598af629dec7b735", ObjectName: []byte("branch-test.txt")},
+ {OID: treeA},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
},
},
{
desc: "tree without objects returns nothing",
revisions: []string{
- "b95c0fad32f4361845f91d9ce4c1721b52b82793",
+ treeA.String(),
},
expectedResults: nil,
},
{
desc: "revision without disabled walk",
revisions: []string{
- "refs/heads/master",
+ commitB.String(),
},
options: []RevlistOption{
WithDisabledWalk(),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
+ {OID: commitB},
},
},
{
desc: "revision range",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ "^" + commitB.String() + "~",
+ commitB.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "07f8147e8e73aab6c935c296e8cdc5194dee729b"},
- {OID: "ceb102b8d3f9a95c2eb979213e49f7cc1b23d56e", ObjectName: []byte("files")},
- {OID: "2132d150328bd9334cc4e62a16a5d998a7e399b9", ObjectName: []byte("files/flat")},
- {OID: "f3942dc8b824a2c9359e518d48e68f84461bd2f7", ObjectName: []byte("files/flat/path")},
- {OID: "ea7249055466085d0a6c69951908ef47757e92f4", ObjectName: []byte("files/flat/path/correct")},
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
+ {OID: commitB},
+ {OID: treeB},
+ {OID: subtree, ObjectName: []byte("subtree")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
{
desc: "revision range without objects",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ "^" + commitB.String() + "~",
+ commitB.String(),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
+ {OID: commitB},
},
},
{
desc: "revision range without objects with at most one parent",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithMaxParents(1),
},
expectedResults: []RevisionResult{
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
+ {OID: commitAParent},
+ {OID: commitBParent},
+ {OID: commitA},
+ {OID: commitB},
},
},
{
desc: "reverse revision range without objects",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ commitB.String(),
},
options: []RevlistOption{
WithReverse(),
},
expectedResults: []RevisionResult{
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
+ {OID: commitA},
+ {OID: commitB},
},
},
{
desc: "reverse revision range with objects",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ commitB.String(),
},
options: []RevlistOption{
WithReverse(),
@@ -190,110 +233,86 @@ func TestRevlist(t *testing.T) {
expectedResults: []RevisionResult{
// Note that only commits are listed in reverse,
// their referenced objects stay in the same order.
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
- {OID: "07f8147e8e73aab6c935c296e8cdc5194dee729b"},
- {OID: "ceb102b8d3f9a95c2eb979213e49f7cc1b23d56e", ObjectName: []byte("files")},
- {OID: "2132d150328bd9334cc4e62a16a5d998a7e399b9", ObjectName: []byte("files/flat")},
- {OID: "f3942dc8b824a2c9359e518d48e68f84461bd2f7", ObjectName: []byte("files/flat/path")},
- {OID: "ea7249055466085d0a6c69951908ef47757e92f4", ObjectName: []byte("files/flat/path/correct")},
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
+ {OID: commitA},
+ {OID: treeA},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
+ {OID: commitB},
+ {OID: treeB},
+ {OID: subtree, ObjectName: []byte("subtree")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
{
desc: "revision range with topo order",
revisions: []string{
- // This is one of the smaller examples I've found which reproduces
- // different sorting orders between topo- and date-sorting. Expected
- // results contain the same object for this and the next test case,
- // but ordering is different.
- "master",
- "^master~5",
- "flat-path",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithOrder(OrderTopo),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
- {OID: "7975be0116940bf2ad4321f79d02a55c5f7779aa"},
- {OID: "c84ff944ff4529a70788a5e9003c2b7feae29047"},
- {OID: "60ecb67744cb56576c30214ff52294f8ce2def98"},
- {OID: "55bc176024cfa3baaceb71db584c7e5df900ea65"},
- {OID: "e63f41fe459e62e1228fcef60d7189127aeba95a"},
- {OID: "4a24d82dbca5c11c61556f3b35ca472b7463187e"},
- {OID: "b83d6e391c22777fca1ed3012fce84f633d7fed0"},
- {OID: "498214de67004b1da3d820901307bed2a68a8ef6"},
- // The following commit is sorted differently in the next testcase.
- {OID: "ce369011c189f62c815f5971d096b26759bab0d1"},
+ // Note that the order here is different from the order in the next
+ // testcase, where we use date-order.
+ {OID: mergeCommit},
+ {OID: commitBParent},
+ {OID: commitB},
+ {OID: commitAParent},
+ {OID: commitA},
},
},
{
desc: "revision range with date order",
revisions: []string{
- "master",
- "^master~5",
- "flat-path",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithOrder(OrderDate),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
- {OID: "7975be0116940bf2ad4321f79d02a55c5f7779aa"},
- {OID: "c84ff944ff4529a70788a5e9003c2b7feae29047"},
- {OID: "60ecb67744cb56576c30214ff52294f8ce2def98"},
- {OID: "55bc176024cfa3baaceb71db584c7e5df900ea65"},
- // The following commit is sorted differently in the previous
- // testcase.
- {OID: "ce369011c189f62c815f5971d096b26759bab0d1"},
- {OID: "e63f41fe459e62e1228fcef60d7189127aeba95a"},
- {OID: "4a24d82dbca5c11c61556f3b35ca472b7463187e"},
- {OID: "b83d6e391c22777fca1ed3012fce84f633d7fed0"},
- {OID: "498214de67004b1da3d820901307bed2a68a8ef6"},
+ {OID: mergeCommit},
+ {OID: commitAParent},
+ {OID: commitBParent},
+ {OID: commitB},
+ {OID: commitA},
},
},
{
desc: "revision range with dates",
revisions: []string{
- "refs/heads/master",
+ mergeCommit.String(),
},
options: []RevlistOption{
- WithBefore(time.Date(2016, 6, 30, 18, 30, 0, 0, time.UTC)),
- WithAfter(time.Date(2016, 6, 30, 18, 28, 0, 0, time.UTC)),
+ WithBefore(time.Date(2000, 12, 1, 1, 1, 1, 1, time.UTC)),
+ WithAfter(time.Date(1999, 12, 1, 1, 1, 1, 1, time.UTC)),
},
expectedResults: []RevisionResult{
- {OID: "6907208d755b60ebeacb2e9dfea74c92c3449a1f"},
- {OID: "c347ca2e140aa667b968e51ed0ffe055501fe4f4"},
+ {OID: commitA},
},
},
{
desc: "revision range with author",
revisions: []string{
- "refs/heads/master",
+ mergeCommit.String(),
},
options: []RevlistOption{
- WithAuthor([]byte("Sytse")),
+ WithAuthor([]byte("custom author")),
},
expectedResults: []RevisionResult{
- {OID: "e56497bb5f03a90a51293fc6d516788730953899"},
+ {OID: commitB},
},
},
{
desc: "first parent chain",
revisions: []string{
- "master",
- "^master~4",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithFirstParent(),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "7975be0116940bf2ad4321f79d02a55c5f7779aa"},
- {OID: "60ecb67744cb56576c30214ff52294f8ce2def98"},
- {OID: "e63f41fe459e62e1228fcef60d7189127aeba95a"},
+ {OID: mergeCommit},
+ {OID: commitAParent},
+ {OID: commitA},
},
},
{
@@ -305,22 +324,16 @@ func TestRevlist(t *testing.T) {
// twice, once without and once with limit.
desc: "tree with multiple blobs without limit",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ treeB.String(),
},
options: []RevlistOption{
WithObjects(),
},
expectedResults: []RevisionResult{
- {OID: "79d5f98270ad677c86a7e1ab2baa922958565135"},
- {OID: "8af7f880ce38649fc49f66e3f38857bfbec3f0b7", ObjectName: []byte("feature-1.txt")},
- {OID: "16ca0b267f82cd2f5ca1157dd162dae98745eab8", ObjectName: []byte("feature-2.txt")},
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "4ae6c5e14452a35d04156277ae63e8356eb17cae", ObjectName: []byte("hotfix-2.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
- {OID: "570f8e1dfe8149c1d17002712310d43dfeb43159", ObjectName: []byte("russian.rb")},
- {OID: "7a17968582c21c9153ec24c6a9d5f33592ad9103", ObjectName: []byte("test.txt")},
- {OID: "f3064a3aa9c14277483f690250072e987e2c8356", ObjectName: []byte("\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt")},
- {OID: "3a26c18b02e843b459732e7ade7ab9a154a1002b", ObjectName: []byte("\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.xls")},
+ {OID: treeB},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
+ {OID: subtree, ObjectName: []byte("subtree")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
{
@@ -328,38 +341,30 @@ func TestRevlist(t *testing.T) {
// get less blobs as result.
desc: "tree with multiple blobs with limit",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ treeB.String(),
},
options: []RevlistOption{
WithObjects(),
- WithBlobLimit(10),
+ WithBlobLimit(5),
},
expectedResults: []RevisionResult{
- {OID: "79d5f98270ad677c86a7e1ab2baa922958565135"},
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "4ae6c5e14452a35d04156277ae63e8356eb17cae", ObjectName: []byte("hotfix-2.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
+ {OID: treeB},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
+ {OID: subtree, ObjectName: []byte("subtree")},
},
},
{
desc: "tree with blob object type filter",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ treeB.String(),
},
options: []RevlistOption{
WithObjects(),
WithObjectTypeFilter(ObjectTypeBlob),
},
expectedResults: []RevisionResult{
- {OID: "8af7f880ce38649fc49f66e3f38857bfbec3f0b7", ObjectName: []byte("feature-1.txt")},
- {OID: "16ca0b267f82cd2f5ca1157dd162dae98745eab8", ObjectName: []byte("feature-2.txt")},
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "4ae6c5e14452a35d04156277ae63e8356eb17cae", ObjectName: []byte("hotfix-2.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
- {OID: "570f8e1dfe8149c1d17002712310d43dfeb43159", ObjectName: []byte("russian.rb")},
- {OID: "7a17968582c21c9153ec24c6a9d5f33592ad9103", ObjectName: []byte("test.txt")},
- {OID: "f3064a3aa9c14277483f690250072e987e2c8356", ObjectName: []byte("\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt")},
- {OID: "3a26c18b02e843b459732e7ade7ab9a154a1002b", ObjectName: []byte("\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.xls")},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
{
@@ -372,53 +377,48 @@ func TestRevlist(t *testing.T) {
WithObjectTypeFilter(ObjectTypeTag),
},
expectedResults: []RevisionResult{
- {OID: "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8", ObjectName: []byte("v1.0.0")},
- {OID: "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b", ObjectName: []byte("v1.1.0")},
- {OID: "8f03acbcd11c53d9c9468078f32a2622005a4841", ObjectName: []byte("v1.1.1")},
+ {OID: tag, ObjectName: []byte("v1.0.0")},
},
},
{
- desc: "tree with commit object type filter",
+ desc: "tree with tree object type filter",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ commitA.String(),
},
options: []RevlistOption{
WithObjects(),
WithObjectTypeFilter(ObjectTypeTree),
},
expectedResults: []RevisionResult{
- {OID: "79d5f98270ad677c86a7e1ab2baa922958565135"},
+ {OID: treeA},
},
},
{
desc: "tree with commit object type filter",
revisions: []string{
- "^refs/heads/master~",
- "refs/heads/master",
+ commitB.String(),
},
options: []RevlistOption{
WithObjects(),
WithObjectTypeFilter(ObjectTypeCommit),
},
expectedResults: []RevisionResult{
- {OID: "1e292f8fedd741b75372e19097c76d327140c312"},
- {OID: "c1c67abbaf91f624347bb3ae96eabe3a1b742478"},
+ {OID: commitB},
+ {OID: commitA},
},
},
{
desc: "tree with object type and blob size filter",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithObjects(),
- WithBlobLimit(10),
+ WithBlobLimit(5),
WithObjectTypeFilter(ObjectTypeBlob),
},
expectedResults: []RevisionResult{
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "4ae6c5e14452a35d04156277ae63e8356eb17cae", ObjectName: []byte("hotfix-2.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
},
},
{
@@ -434,7 +434,7 @@ func TestRevlist(t *testing.T) {
{
desc: "mixed valid and invalid revision",
revisions: []string{
- lfsPointer1,
+ blobA.String(),
"refs/heads/does-not-exist",
},
expectedErr: errors.New("rev-list pipeline command: exit status 128, stderr: " +
@@ -445,11 +445,10 @@ func TestRevlist(t *testing.T) {
{
desc: "skip everything",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithObjects(),
- WithBlobLimit(10),
WithObjectTypeFilter(ObjectTypeBlob),
WithSkipRevlistResult(func(*RevisionResult) bool { return true }),
},
@@ -457,36 +456,32 @@ func TestRevlist(t *testing.T) {
{
desc: "skip nothing",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithObjects(),
- WithBlobLimit(10),
WithObjectTypeFilter(ObjectTypeBlob),
WithSkipRevlistResult(func(*RevisionResult) bool { return false }),
},
expectedResults: []RevisionResult{
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "4ae6c5e14452a35d04156277ae63e8356eb17cae", ObjectName: []byte("hotfix-2.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
+ {OID: blob, ObjectName: []byte("branch-test.txt")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
{
desc: "skip one",
revisions: []string{
- "79d5f98270ad677c86a7e1ab2baa922958565135",
+ mergeCommit.String(),
},
options: []RevlistOption{
WithObjects(),
- WithBlobLimit(10),
WithObjectTypeFilter(ObjectTypeBlob),
WithSkipRevlistResult(func(r *RevisionResult) bool {
- return string(r.ObjectName) == "hotfix-2.txt"
+ return bytes.Equal(r.ObjectName, []byte("branch-test.txt"))
}),
},
expectedResults: []RevisionResult{
- {OID: "0fb47f093f769008049a0b0976ac3fa6d6125033", ObjectName: []byte("hotfix-1.txt")},
- {OID: "b988ffed90cb6a9b7f98a3686a933edb3c5d70c0", ObjectName: []byte("iso8859.txt")},
+ {OID: subblob, ObjectName: []byte("subtree/subblob")},
},
},
} {
@@ -513,12 +508,12 @@ func TestRevlist(t *testing.T) {
t.Run("context cancellation", func(t *testing.T) {
ctx, cancel := context.WithCancel(testhelper.Context(t))
- it := Revlist(ctx, repo, []string{"refs/heads/master"})
+ it := Revlist(ctx, repo, []string{mergeCommit.String()})
require.True(t, it.Next())
require.NoError(t, it.Err())
require.Equal(t, RevisionResult{
- OID: "1e292f8fedd741b75372e19097c76d327140c312",
+ OID: mergeCommit,
}, it.Result())
cancel()