diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-06-23 17:39:49 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-06-27 14:37:50 +0300 |
commit | e79599c94e72b41fa94710a4e3261117f21c802e (patch) | |
tree | 88441ef7c8fa91cd6f91f3f1c166ced23bba283b | |
parent | d73b6013db70d050dde9188236cc5036b8691485 (diff) |
operations: Demonstrate broken test to verify squashing with rename
One of our tests tries to verify that we can squash a commit when there
was a rename on the target branch. This test is silently broken though
because of the way we set up the commits: while we do rename the changed
file, the commit containing that change is not used to compute the
squash.
Demonstrate this brokenness by asserting the tree's contents. As can be
seen, the resulting tree has the changed content but is still using the
original filename.
-rw-r--r-- | internal/gitaly/service/operations/squash_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go index 72d741ac1..3c5a64d82 100644 --- a/internal/gitaly/service/operations/squash_test.go +++ b/internal/gitaly/service/operations/squash_test.go @@ -323,7 +323,11 @@ func TestUserSquash_renames(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) + + repoProto, repoPath := gittest.CreateRepository(ctx, t, cfg) + + gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(), gittest.WithBranch("main")) gittest.AddWorktree(t, cfg, repoPath, "worktree") repoPath = filepath.Join(repoPath, "worktree") @@ -333,7 +337,7 @@ func TestUserSquash_renames(t *testing.T) { originalFilename := "original-file.txt" renamedFilename := "renamed-file.txt" - gittest.Exec(t, cfg, "-C", repoPath, "checkout", "-b", "squash-rename-test", "master") + gittest.Exec(t, cfg, "-C", repoPath, "checkout", "-b", "squash-rename-test", "main") require.NoError(t, os.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is a test"), 0o644)) gittest.Exec(t, cfg, "-C", repoPath, "add", ".") gittest.Exec(t, cfg, "-C", repoPath, "commit", "-m", "test file") @@ -375,6 +379,10 @@ func TestUserSquash_renames(t *testing.T) { require.Equal(t, gittest.TimezoneOffset, string(commit.Committer.Timezone)) require.Equal(t, gittest.TimezoneOffset, string(commit.Author.Timezone)) require.Equal(t, commitMessage, commit.Subject) + + gittest.RequireTree(t, cfg, repoPath, response.SquashSha, []gittest.TreeEntry{ + {Path: originalFilename, Mode: "100644", Content: "This is another change", OID: "1b2ae89cca65f0d514f677981f012d708df651fc"}, + }) } func TestUserSquash_missingFileOnTargetBranch(t *testing.T) { |