storj/pkg/overlay/service_test.go
JT Olio fa390c9ec9
Mock overlay move (#245)
* move mock overlay from client to server

this doesn't really change much, but it does allow you to
run a standalone gateway against captain planet. it still does
not allow you to run a standalone gateway against a standalone
heavy client

* pointerdb: small error fixes

* some cleanups

* fix tests
2018-08-20 14:24:11 -04:00

52 lines
1.1 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package overlay
import (
"context"
"fmt"
"net"
"testing"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
proto "storj.io/storj/protos/overlay" // naming proto to avoid confusion with this package
)
func TestNewServer(t *testing.T) {
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 0))
assert.NoError(t, err)
srv := newMockServer()
assert.NotNil(t, srv)
go srv.Serve(lis)
srv.Stop()
}
func newMockServer(opts ...grpc.ServerOption) *grpc.Server {
grpcServer := grpc.NewServer(opts...)
proto.RegisterOverlayServer(grpcServer, &TestMockOverlay{})
return grpcServer
}
type TestMockOverlay struct{}
func (o *TestMockOverlay) FindStorageNodes(ctx context.Context, req *proto.FindStorageNodesRequest) (*proto.FindStorageNodesResponse, error) {
return &proto.FindStorageNodesResponse{}, nil
}
func (o *TestMockOverlay) Lookup(ctx context.Context, req *proto.LookupRequest) (*proto.LookupResponse, error) {
return &proto.LookupResponse{}, nil
}
func TestNewServerNilArgs(t *testing.T) {
server := NewServer(nil, nil, nil, nil)
assert.NotNil(t, server)
}