diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-11-20 18:00:06 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-11-29 16:34:59 +0300 |
commit | 571694f657f765387f71d6908a30f612df7048a0 (patch) | |
tree | cf25193c0a7004dfd6a39bb7484b265850341a6e /internal/testhelper | |
parent | 8ea5e64f46071af630955a455354e93f98e4d7e2 (diff) |
Implement UserCherryPick RPC
Closes #736
Diffstat (limited to 'internal/testhelper')
-rw-r--r-- | internal/testhelper/testhelper.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index 3756d19b5..5933c6dbf 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -3,6 +3,8 @@ package testhelper import ( "bytes" "context" + "encoding/base64" + "encoding/json" "fmt" "io" "io/ioutil" @@ -27,10 +29,14 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" ) // TestRelativePath is the path inside its storage of the gitlab-test repo -const TestRelativePath = "gitlab-test.git" +const ( + TestRelativePath = "gitlab-test.git" + RepositoryAuthToken = "the-secret-token" +) // MustReadFile returns the content of a file or fails at once. func MustReadFile(t *testing.T, filename string) []byte { @@ -70,6 +76,24 @@ func ConfigureTestStorage() { } } +// GitalyServersMetadata returns a metadata pair for gitaly-servers to be used in +// inter-gitaly operations. +func GitalyServersMetadata(t *testing.T, serverSocketPath string) metadata.MD { + gitalyServers := map[string]map[string]string{ + "default": { + "address": "unix:" + serverSocketPath, + "token": RepositoryAuthToken, + }, + } + + gitalyServersJSON, err := json.Marshal(gitalyServers) + if err != nil { + t.Fatal(err) + } + + return metadata.Pairs("gitaly-servers", base64.StdEncoding.EncodeToString(gitalyServersJSON)) +} + func testRepoValid(repo *pb.Repository) bool { storagePath, _ := config.StoragePath(repo.GetStorageName()) if _, err := os.Stat(path.Join(storagePath, repo.RelativePath, "objects")); err != nil { |