This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2017-05-03 07:30:18 +02:00
|
|
|
// Package with the mostly static content (models) of this microservice
|
2017-04-04 19:28:46 +02:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-04-04 23:21:05 +02:00
|
|
|
"github.com/genofire/hs_master-kss-monolith/lib/database"
|
2017-04-04 19:28:46 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2017-05-03 07:30:18 +02:00
|
|
|
// Function to test the locking and unlocking of a good
|
2017-04-04 19:28:46 +02:00
|
|
|
func TestGood(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2017-04-07 11:56:28 +02:00
|
|
|
database.Open(database.Config{
|
|
|
|
Type: "sqlite3",
|
|
|
|
Logging: true,
|
|
|
|
Connection: ":memory:",
|
|
|
|
})
|
|
|
|
|
2017-04-04 19:28:46 +02:00
|
|
|
good := &Good{}
|
|
|
|
assert.False(good.IsLock())
|
|
|
|
|
|
|
|
good.Lock("blub_secret")
|
|
|
|
assert.True(good.IsLock())
|
|
|
|
|
|
|
|
err := good.Unlock("secret")
|
|
|
|
assert.Error(err)
|
|
|
|
assert.True(good.IsLock())
|
|
|
|
|
|
|
|
good.Unlock("blub_secret")
|
|
|
|
assert.False(good.IsLock())
|
2017-04-04 23:21:05 +02:00
|
|
|
|
|
|
|
assert.NotNil(good.FilterAvailable(database.Read))
|
|
|
|
|
2017-04-04 19:28:46 +02:00
|
|
|
}
|