2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-08 14:19:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package satellitedb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2018-11-30 13:40:13 +00:00
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
dbx "storj.io/storj/satellite/satellitedb/dbx"
|
2018-11-08 14:19:42 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 12:05:24 +00:00
|
|
|
func TestUserFromDbx(t *testing.T) {
|
2018-11-08 14:19:42 +00:00
|
|
|
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
|
|
|
user, err := userFromDBX(nil)
|
|
|
|
assert.Nil(t, user)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
|
2018-11-09 12:05:24 +00:00
|
|
|
t.Run("can't create dbo from dbx model with invalid ID", func(t *testing.T) {
|
2018-11-08 14:19:42 +00:00
|
|
|
dbxUser := dbx.User{
|
2018-11-09 12:05:24 +00:00
|
|
|
Id: []byte("qweqwe"),
|
2018-11-08 14:19:42 +00:00
|
|
|
FirstName: "FirstName",
|
|
|
|
LastName: "LastName",
|
2019-01-30 15:04:40 +00:00
|
|
|
Email: nil,
|
2018-11-08 14:19:42 +00:00
|
|
|
PasswordHash: []byte("ihqerfgnu238723huagsd"),
|
|
|
|
CreatedAt: time.Now(),
|
|
|
|
}
|
|
|
|
|
|
|
|
user, err := userFromDBX(&dbxUser)
|
|
|
|
|
|
|
|
assert.Nil(t, user)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|