summaryrefslogtreecommitdiff
path: root/go/cmd/gitaly-upload-archive/main_test.go
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2019-02-25 16:19:08 +0200
committerAndrew Newdigate <andrew@gitlab.com>2019-03-01 15:07:23 +0200
commit210a5c141c9d76bc9718860d67d77d73997b1534 (patch)
treee8bfe028d6ecb5ddc269b67283b7b52240323dde /go/cmd/gitaly-upload-archive/main_test.go
parent070691c29891c27f0e46f86f6c89566199ccc54b (diff)
downloadgitlab-shell-an-distributed-tracing.tar.gz
Adds distributed tracing instrumentation to GitLab-Shellan-distributed-tracing
Adds distributed tracing instrumentation to GitLab-Shell using LabKit
Diffstat (limited to 'go/cmd/gitaly-upload-archive/main_test.go')
-rw-r--r--go/cmd/gitaly-upload-archive/main_test.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/go/cmd/gitaly-upload-archive/main_test.go b/go/cmd/gitaly-upload-archive/main_test.go
deleted file mode 100644
index 1f30e56..0000000
--- a/go/cmd/gitaly-upload-archive/main_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package main
-
-import (
- "fmt"
- "strings"
- "testing"
-
- pb "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb"
-)
-
-var testGitalyAddress = "unix:gitaly.socket"
-
-func TestUploadArchiveSuccess(t *testing.T) {
- testRelativePath := "myrepo.git"
- requestJSON := fmt.Sprintf(`{"repository":{"relative_path":"%s"}}`, testRelativePath)
- mockHandler := func(gitalyAddress string, request *pb.SSHUploadArchiveRequest) (int32, error) {
- if gitalyAddress != testGitalyAddress {
- t.Fatalf("Expected gitaly address %s got %v", testGitalyAddress, gitalyAddress)
- }
- if relativePath := request.Repository.RelativePath; relativePath != testRelativePath {
- t.Fatalf("Expected repository with relative path %s got %v", testRelativePath, request)
- }
- return 0, nil
- }
-
- code, err := uploadArchive(mockHandler, []string{"git-upload-archive", testGitalyAddress, requestJSON})
-
- if err != nil {
- t.Fatal(err)
- }
-
- if code != 0 {
- t.Fatalf("Expected exit code 0, got %v", code)
- }
-}
-
-func TestUploadArchiveFailure(t *testing.T) {
- mockHandler := func(_ string, _ *pb.SSHUploadArchiveRequest) (int32, error) {
- t.Fatal("Expected handler not to be called")
-
- return 0, nil
- }
-
- tests := []struct {
- desc string
- args []string
- err string
- }{
- {
- desc: "With an invalid request json",
- args: []string{"git-upload-archive", testGitalyAddress, "hello"},
- err: "unmarshaling request json failed",
- },
- {
- desc: "With an invalid argument count",
- args: []string{"git-upload-archive", testGitalyAddress, "{}", "extra arg"},
- err: "wrong number of arguments: expected 2 arguments",
- },
- }
-
- for _, test := range tests {
- t.Run(test.desc, func(t *testing.T) {
- _, err := uploadArchive(mockHandler, test.args)
-
- if !strings.Contains(err.Error(), test.err) {
- t.Fatalf("Expected error %v, got %v", test.err, err)
- }
- })
- }
-}