2018-07-27 02:10:05 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2018-07-27 04:45:42 +00:00
|
|
|
"github.com/hunterlong/statup/utils"
|
2018-07-27 02:10:05 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-07-27 04:45:42 +00:00
|
|
|
"os"
|
2018-07-27 02:10:05 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-07-28 01:50:13 +00:00
|
|
|
testCore *Core
|
|
|
|
testConfig *DbConfig
|
|
|
|
gopath string
|
2018-07-27 02:10:05 +00:00
|
|
|
)
|
|
|
|
|
2018-07-27 04:45:42 +00:00
|
|
|
func init() {
|
2018-07-28 01:50:13 +00:00
|
|
|
gopath = os.Getenv("GOPATH")
|
|
|
|
gopath += "/src/github.com/hunterlong/statup"
|
2018-07-27 04:45:42 +00:00
|
|
|
|
|
|
|
utils.InitLogs()
|
|
|
|
RenderBoxes()
|
|
|
|
}
|
|
|
|
|
2018-07-27 02:10:05 +00:00
|
|
|
func TestNewCore(t *testing.T) {
|
|
|
|
testCore = NewCore()
|
|
|
|
assert.NotNil(t, testCore)
|
2018-07-27 04:45:42 +00:00
|
|
|
testCore.Name = "Tester"
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDbConfig_Save(t *testing.T) {
|
|
|
|
testConfig = &DbConfig{
|
|
|
|
DbConn: "sqlite",
|
|
|
|
Project: "Tester",
|
2018-07-28 01:50:13 +00:00
|
|
|
Location: gopath,
|
2018-07-27 04:45:42 +00:00
|
|
|
}
|
|
|
|
err := testConfig.Save()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDbConnection(t *testing.T) {
|
2018-07-28 01:50:13 +00:00
|
|
|
err := DbConnection(testConfig.DbConn, false, gopath)
|
2018-07-27 04:45:42 +00:00
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateDatabase(t *testing.T) {
|
|
|
|
err := CreateDatabase()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInsertCore(t *testing.T) {
|
|
|
|
err := InsertCore(testCore)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSelectCore(t *testing.T) {
|
|
|
|
core, err := SelectCore()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, "Tester", core.Name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSampleData(t *testing.T) {
|
|
|
|
err := LoadSampleData()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSelectLastMigration(t *testing.T) {
|
|
|
|
id, err := SelectLastMigration()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotZero(t, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCore_UsingAssets(t *testing.T) {
|
|
|
|
assert.False(t, testCore.UsingAssets())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHasAssets(t *testing.T) {
|
2018-07-28 01:50:13 +00:00
|
|
|
assert.False(t, HasAssets(gopath))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateAssets(t *testing.T) {
|
|
|
|
assert.Nil(t, CreateAllAssets(gopath))
|
|
|
|
assert.True(t, HasAssets(gopath))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCompileSASS(t *testing.T) {
|
|
|
|
t.SkipNow()
|
|
|
|
os.Setenv("SASS", "sass")
|
|
|
|
os.Setenv("CMD_FILE", gopath+"/cmd.sh")
|
|
|
|
assert.Nil(t, CompileSASS(gopath))
|
|
|
|
assert.True(t, HasAssets(gopath))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDeleteAssets(t *testing.T) {
|
|
|
|
assert.Nil(t, DeleteAllAssets(gopath))
|
|
|
|
assert.False(t, HasAssets(gopath))
|
2018-07-27 04:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestInsertNotifierDB(t *testing.T) {
|
|
|
|
err := InsertNotifierDB()
|
|
|
|
assert.Nil(t, err)
|
2018-07-27 02:10:05 +00:00
|
|
|
}
|