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:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-04-03 13:56:12 +0300
committerJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-04-03 13:56:12 +0300
commit71f274fefac48b241cf528359f7063b6a118e4bb (patch)
tree1f14c1a4054b09c060b60d507e14c352a0b78a32
parentc39b07a61a1802a2458e74f33a933ef5ec4d5749 (diff)
parentfe85c02785c05d21c474176102c54da4b7d0ac69 (diff)
Merge branch 'fix/use-table-format-in-tests' into 'master'
Use table-format tests for Diff service See merge request !116
-rw-r--r--internal/service/diff/commit_test.go62
1 files changed, 14 insertions, 48 deletions
diff --git a/internal/service/diff/commit_test.go b/internal/service/diff/commit_test.go
index 509992516..9b7a7b764 100644
--- a/internal/service/diff/commit_test.go
+++ b/internal/service/diff/commit_test.go
@@ -214,66 +214,32 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
}
}
-func TestFailedCommitDiffRequestWithEmptyRepository(t *testing.T) {
+func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) {
server := runDiffServer(t)
defer server.Stop()
client := newDiffClient(t)
- repo := &pb.Repository{Path: ""}
rightCommit := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72"
leftCommit := rightCommit + "~" // Parent of rightCommit
- // Case: Repository.Path is empty
- rpcRequest := &pb.CommitDiffRequest{Repository: repo, RightCommitId: rightCommit, LeftCommitId: leftCommit}
-
- c, err := client.CommitDiff(context.Background(), rpcRequest)
- if err != nil {
- t.Fatal(err)
- }
-
- err = drainCommitDiffResponse(c)
- testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "")
-
- // Case: Repository is nil
- rpcRequest = &pb.CommitDiffRequest{Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}
- c, err = client.CommitDiff(context.Background(), rpcRequest)
- if err != nil {
- t.Fatal(err)
+ rpcRequests := []pb.CommitDiffRequest{
+ {Repository: &pb.Repository{Path: ""}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository.Path is empty
+ {Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository is nil
+ {Repository: &pb.Repository{Path: testRepoPath}, RightCommitId: "", LeftCommitId: leftCommit}, // RightCommitId is empty
+ {Repository: &pb.Repository{Path: testRepoPath}, RightCommitId: rightCommit, LeftCommitId: ""}, // LeftCommitId is empty
}
- err = drainCommitDiffResponse(c)
- testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "")
-}
+ for _, rpcRequest := range rpcRequests {
+ t.Logf("test case: %v", rpcRequest)
-func TestFailedCommitDiffRequestWithEmptyCommit(t *testing.T) {
- server := runDiffServer(t)
- defer server.Stop()
-
- client := newDiffClient(t)
- repo := &pb.Repository{Path: testRepoPath}
- rightCommit := ""
- leftCommit := rightCommit + "~" // Parent of rightCommit
- rpcRequest := &pb.CommitDiffRequest{Repository: repo, RightCommitId: rightCommit, LeftCommitId: leftCommit}
-
- c, err := client.CommitDiff(context.Background(), rpcRequest)
- if err != nil {
- t.Fatal(err)
- }
-
- err = drainCommitDiffResponse(c)
- testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "")
-
- rightCommit = "d42783470dc29fde2cf459eb3199ee1d7e3f3a72"
- leftCommit = ""
- rpcRequest = &pb.CommitDiffRequest{Repository: repo, RightCommitId: rightCommit, LeftCommitId: leftCommit}
+ c, err := client.CommitDiff(context.Background(), &rpcRequest)
+ if err != nil {
+ t.Fatal(err)
+ }
- c, err = client.CommitDiff(context.Background(), rpcRequest)
- if err != nil {
- t.Fatal(err)
+ err = drainCommitDiffResponse(c)
+ testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "")
}
-
- err = drainCommitDiffResponse(c)
- testhelper.AssertGrpcError(t, err, codes.InvalidArgument, "")
}
func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) {