storj/pkg/overlay/service_test.go
Egon Elbre b6b6111173
Flatten proto definitions into a single package (#360)
* protos: move streams to pb
* protos: move overlay to pb
* protos: move pointerdb to pb
* protos: move piecestore to pb
* fix statdb import naming
2018-09-18 07:39:06 +03:00

60 lines
1.3 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package overlay
import (
"context"
"net"
"testing"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"storj.io/storj/pkg/pb"
)
func TestNewServer(t *testing.T) {
t.Skip("flaky")
lis, err := net.Listen("tcp", "127.0.0.1:0")
assert.NoError(t, err)
srv := newMockServer()
assert.NotNil(t, srv)
// TODO: figure out why the error here fails
go func() {
assert.NoError(t, srv.Serve(lis))
}()
srv.Stop()
}
func newMockServer(opts ...grpc.ServerOption) *grpc.Server {
grpcServer := grpc.NewServer(opts...)
pb.RegisterOverlayServer(grpcServer, &TestMockOverlay{})
return grpcServer
}
type TestMockOverlay struct{}
func (o *TestMockOverlay) FindStorageNodes(ctx context.Context, req *pb.FindStorageNodesRequest) (*pb.FindStorageNodesResponse, error) {
return &pb.FindStorageNodesResponse{}, nil
}
func (o *TestMockOverlay) Lookup(ctx context.Context, req *pb.LookupRequest) (*pb.LookupResponse, error) {
return &pb.LookupResponse{}, nil
}
func (o *TestMockOverlay) BulkLookup(ctx context.Context, reqs *pb.LookupRequests) (*pb.LookupResponses, error) {
return &pb.LookupResponses{}, nil
}
func TestNewServerNilArgs(t *testing.T) {
server := NewServer(nil, nil, nil, nil)
assert.NotNil(t, server)
}