Git designed for AI agents.
package remote
import (
"context"
"testing"
"github.com/feder-cr/git-ai/internal/gitaly/config"
"github.com/feder-cr/git-ai/internal/gitaly/service"
"github.com/feder-cr/git-ai/internal/gitaly/service/repository"
"github.com/feder-cr/git-ai/internal/grpc/client"
"github.com/feder-cr/git-ai/internal/testhelper"
"github.com/feder-cr/git-ai/internal/testhelper/testcfg"
"github.com/feder-cr/git-ai/internal/testhelper/testserver"
"github.com/feder-cr/git-ai/proto/go/gitalypb"
"google.golang.org/grpc"
)
func TestMain(m *testing.M) {
testhelper.Run(m)
}
func setupRemoteService(t *testing.T, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, gitalypb.RemoteServiceClient) {
t.Helper()
cfg := testcfg.Build(t)
addr := testserver.RunGitalyServer(t, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterRemoteServiceServer(srv, NewServer(deps))
gitalypb.RegisterRepositoryServiceServer(srv, repository.NewServer(deps))
}, opts...)
cfg.SocketPath = addr
client, conn := newRemoteClient(t, addr)
t.Cleanup(func() { conn.Close() })
return cfg, client
}
func newRemoteClient(t *testing.T, serverSocketPath string) (gitalypb.RemoteServiceClient, *grpc.ClientConn) {
t.Helper()
conn, err := client.New(testhelper.Context(t), serverSocketPath)
if err != nil {
t.Fatal(err)
}
return gitalypb.NewRemoteServiceClient(conn), conn
}