storj/pkg/overlay/service_test.go
Bryan White 1ebd66d880 Cleanup & bolt-backed cache (#87)
* wip post-demos cleanup

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Reorganize:

storage
├── common
│   └── common.go `package storage`
├── boltdb
│   └── ...
└── redis
    └── ...

storage
├── common.go `package storage`
├── boltdb
│   └── ...
└── redis
    └── ...

storage
├── common
│   ├── common.go `package storage`
│   └── testing.go `package storage` <--
└── ...

internal
├── app
│   └── cli
├── pkg
│   └── readcloser
└── test
    └── util.go `package test` <--

* remove comment

* add and use goimports

* add test types & fix some lint errors

* better typing

* fixing linter issues/comments

* goimports

* goimports

* more linter fixes; replace panic with NoError assertions in tests

* fix typo/more linter errors

* moar better linter fixes

* even moar better linter fixes

* linter

* add localPort back

* fixing exports, imports, and add comments
2018-06-13 14:22:32 -04:00

60 lines
1.2 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package overlay
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"storj.io/storj/internal/test"
proto "storj.io/storj/protos/overlay" // naming proto to avoid confusion with this package
)
func TestNewServer(t *testing.T) {
t.SkipNow()
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 0))
assert.NoError(t, err)
srv := NewServer(nil, nil, nil, nil)
assert.NotNil(t, srv)
go srv.Serve(lis)
srv.Stop()
}
func TestNewClient(t *testing.T) {
//a := "35.232.202.229:8080"
//c, err := NewClient(&a, grpc.WithInsecure())
t.SkipNow()
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 0))
assert.NoError(t, err)
srv := NewServer(nil, nil, nil, nil)
go srv.Serve(lis)
defer srv.Stop()
address := lis.Addr().String()
c, err := NewClient(&address, grpc.WithInsecure())
assert.NoError(t, err)
r, err := c.Lookup(context.Background(), &proto.LookupRequest{})
assert.NoError(t, err)
assert.NotNil(t, r)
}
func TestProcess(t *testing.T) {
done := test.EnsureRedis(t)
defer done()
o := Service{}
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
err := o.Process(ctx)
assert.NoError(t, err)
}