Added unit tests for status

This commit is contained in:
konrad 2018-01-16 16:13:17 +01:00 committed by kolaente
parent b613208950
commit 3c5af74141
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 31 additions and 0 deletions

31
models/status_test.go Normal file
View File

@ -0,0 +1,31 @@
package models
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetStatusList(t *testing.T) {
// Create test database
assert.NoError(t, PrepareTestDatabase())
// Insert some dummy data
_, err := x.Insert(Status{Name: "new"})
assert.NoError(t, err)
_, err = x.Insert(Status{Name: "used"})
assert.NoError(t, err)
_, err = x.Insert(Status{Name: "other"})
assert.NoError(t, err)
// Get a status list
list, err := GetStatusList()
assert.NoError(t, err)
assert.Equal(t, "new", list[0].Name)
assert.Equal(t, "used", list[1].Name)
assert.Equal(t, "other", list[2].Name)
// Get a status by its ID
status, err := GetStatusByID(1)
assert.NoError(t, err)
assert.Equal(t, "new", status.Name)
}