2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-13 08:27:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package satellitedb
|
|
|
|
|
|
|
|
import (
|
2019-06-04 12:55:38 +01:00
|
|
|
"context"
|
2018-11-13 08:27:42 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2018-11-29 18:39:27 +00:00
|
|
|
|
2019-01-16 20:23:28 +00:00
|
|
|
dbx "storj.io/storj/satellite/satellitedb/dbx"
|
2018-11-13 08:27:42 +00:00
|
|
|
)
|
|
|
|
|
2019-06-04 12:55:38 +01:00
|
|
|
var (
|
|
|
|
ctx = context.Background() // test context
|
|
|
|
)
|
|
|
|
|
2018-11-13 08:27:42 +00:00
|
|
|
func TestProjectFromDbx(t *testing.T) {
|
|
|
|
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
2019-06-04 12:55:38 +01:00
|
|
|
project, err := projectFromDBX(ctx, nil)
|
2018-11-13 08:27:42 +00:00
|
|
|
|
2018-11-14 12:45:49 +00:00
|
|
|
assert.Nil(t, project)
|
2018-11-13 08:27:42 +00:00
|
|
|
assert.NotNil(t, err)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("can't create dbo from dbx model with invalid ID", func(t *testing.T) {
|
|
|
|
dbxProject := dbx.Project{
|
|
|
|
Id: []byte("qweqwe"),
|
|
|
|
}
|
|
|
|
|
2019-06-04 12:55:38 +01:00
|
|
|
project, err := projectFromDBX(ctx, &dbxProject)
|
2018-11-13 08:27:42 +00:00
|
|
|
|
|
|
|
assert.Nil(t, project)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|