storj/pkg/overlay/config_test.go
Michal Niewrzal a819d819e3
Overlay Cache master db merge (#877)
* Overlay Cache master db merge

* test update

* review comments

* Fix transaction usage

* removed unused variable

* added better limit handling

* better error handling
2018-12-17 21:14:16 +01:00

31 lines
741 B
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package overlay
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"storj.io/storj/pkg/kademlia"
)
func TestRun(t *testing.T) {
bctx := context.Background()
kad := &kademlia.Kademlia{}
var kadKey kademlia.CtxKey
ctx := context.WithValue(bctx, kadKey, kad)
// run with nil
err := Config{}.Run(context.Background(), nil)
assert.Error(t, err)
assert.Equal(t, "overlay error: programmer error: kademlia responsibility unstarted", err.Error())
// run with nil, pass pointer to Kademlia in context
err = Config{}.Run(ctx, nil)
assert.Error(t, err)
assert.Equal(t, "overlay error: unable to get master db instance", err.Error())
}