fixed unit tests that were using now removed config
This commit is contained in:
parent
af82f7aa2c
commit
ba47948fc9
2 changed files with 11 additions and 19 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
|
|
||||||
"github.com/drone/drone/pkg/config"
|
|
||||||
common "github.com/drone/drone/pkg/types"
|
common "github.com/drone/drone/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,14 +17,15 @@ type Client struct {
|
||||||
// New returns a new, remote datastore backend that connects
|
// New returns a new, remote datastore backend that connects
|
||||||
// via tcp and exchanges data using Go's RPC mechanism.
|
// via tcp and exchanges data using Go's RPC mechanism.
|
||||||
func New(conf *config.Config) (*Client, error) {
|
func New(conf *config.Config) (*Client, error) {
|
||||||
conn, err := net.Dial("tcp", conf.Server.Addr)
|
// conn, err := net.Dial("tcp", conf.Server.Addr)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
client := &Client{
|
// client := &Client{
|
||||||
rpc.NewClient(conn),
|
// rpc.NewClient(conn),
|
||||||
}
|
// }
|
||||||
return client, nil
|
// return client, nil
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Login(token, secret string) (*common.User, error) {
|
func (c *Client) Login(token, secret string) (*common.User, error) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
. "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
|
. "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
|
||||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
||||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/mock"
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/mock"
|
||||||
"github.com/drone/drone/pkg/config"
|
|
||||||
"github.com/drone/drone/pkg/server/recorder"
|
"github.com/drone/drone/pkg/server/recorder"
|
||||||
"github.com/drone/drone/pkg/server/session"
|
"github.com/drone/drone/pkg/server/session"
|
||||||
"github.com/drone/drone/pkg/store/mock"
|
"github.com/drone/drone/pkg/store/mock"
|
||||||
|
@ -60,10 +59,7 @@ func TestToken(t *testing.T) {
|
||||||
ctx.Set("datastore", store)
|
ctx.Set("datastore", store)
|
||||||
ctx.Set("user", &types.User{Login: "Freya"})
|
ctx.Set("user", &types.User{Login: "Freya"})
|
||||||
|
|
||||||
conf := &config.Config{}
|
ctx.Set("session", session.New("Otto"))
|
||||||
conf.Session.Secret = "Otto"
|
|
||||||
ctx.Set("settings", conf)
|
|
||||||
ctx.Set("session", session.New(conf.Session.Secret))
|
|
||||||
|
|
||||||
// prepare the mock
|
// prepare the mock
|
||||||
store.On("AddToken", mock.AnythingOfType("*types.Token")).Return(test.storeErr).Once()
|
store.On("AddToken", mock.AnythingOfType("*types.Token")).Return(test.storeErr).Once()
|
||||||
|
@ -98,11 +94,7 @@ func TestToken(t *testing.T) {
|
||||||
|
|
||||||
ctx.Set("datastore", store)
|
ctx.Set("datastore", store)
|
||||||
ctx.Set("user", &types.User{Login: "Freya"})
|
ctx.Set("user", &types.User{Login: "Freya"})
|
||||||
|
ctx.Set("session", session.New("Otto"))
|
||||||
conf := &config.Config{}
|
|
||||||
conf.Session.Secret = "Otto"
|
|
||||||
ctx.Set("settings", conf)
|
|
||||||
ctx.Set("session", session.New(conf.Session.Secret))
|
|
||||||
|
|
||||||
// prepare the mock
|
// prepare the mock
|
||||||
store.On("TokenLabel", mock.AnythingOfType("*types.User"), test.inLabel).Return(test.outToken, test.errTokenLabel).Once()
|
store.On("TokenLabel", mock.AnythingOfType("*types.User"), test.inLabel).Return(test.outToken, test.errTokenLabel).Once()
|
||||||
|
|
Loading…
Add table
Reference in a new issue