mirror of https://github.com/statping/statping
corrected tests
parent
6c28635763
commit
c95e3b85a5
|
@ -305,7 +305,7 @@ func RunUserCreate(t *testing.T) {
|
|||
Username: "hunterlong",
|
||||
Password: "password123",
|
||||
Email: "info@gmail.com",
|
||||
Admin: true,
|
||||
Admin: utils.NullBool(true),
|
||||
})
|
||||
id, err := user.Create()
|
||||
assert.Nil(t, err)
|
||||
|
@ -314,7 +314,7 @@ func RunUserCreate(t *testing.T) {
|
|||
Username: "superadmin",
|
||||
Password: "admin",
|
||||
Email: "info@adminer.com",
|
||||
Admin: true,
|
||||
Admin: utils.NullBool(true),
|
||||
})
|
||||
id, err = user2.Create()
|
||||
assert.Nil(t, err)
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestSelectNotification(t *testing.T) {
|
|||
notifier, err := SelectNotification(example)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "example", notifier.Method)
|
||||
assert.False(t, notifier.Enabled)
|
||||
assert.False(t, notifier.Enabled.Bool)
|
||||
assert.False(t, notifier.IsRunning())
|
||||
}
|
||||
|
||||
|
@ -131,17 +131,17 @@ func TestNotification_Update(t *testing.T) {
|
|||
assert.Equal(t, "http://demo.statup.io/api", example.Host)
|
||||
assert.Equal(t, "USBdu82HDiiuw9327yGYDGw", selected.GetValue("api_key"))
|
||||
assert.Equal(t, "USBdu82HDiiuw9327yGYDGw", example.ApiKey)
|
||||
assert.False(t, selected.Enabled)
|
||||
assert.False(t, selected.Enabled.Bool)
|
||||
assert.False(t, selected.IsRunning())
|
||||
}
|
||||
|
||||
func TestEnableNotification(t *testing.T) {
|
||||
notifier, err := SelectNotification(example)
|
||||
assert.Nil(t, err)
|
||||
notifier.Enabled = true
|
||||
notifier.Enabled = utils.NullBool(true)
|
||||
updated, err := Update(example, notifier)
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, updated.Enabled)
|
||||
assert.True(t, updated.Enabled.Bool)
|
||||
assert.True(t, updated.IsRunning())
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@ func InsertSampleData() error {
|
|||
s4.Create(false)
|
||||
s5.Create(false)
|
||||
|
||||
insertMessages()
|
||||
|
||||
utils.Log(1, "Sample data has finished importing")
|
||||
|
||||
return nil
|
||||
|
@ -182,12 +184,33 @@ func insertSampleUsers() {
|
|||
u3.Create()
|
||||
}
|
||||
|
||||
func insertMessages() {
|
||||
m1 := ReturnMessage(&types.Message{
|
||||
Title: "Routine Downtime",
|
||||
Description: "This is an example a upcoming message for a service!",
|
||||
ServiceId: 1,
|
||||
StartOn: time.Now().Add(15 * time.Minute),
|
||||
EndOn: time.Now().Add(2 * time.Hour),
|
||||
})
|
||||
m1.Create()
|
||||
|
||||
m2 := ReturnMessage(&types.Message{
|
||||
Title: "Server Reboot",
|
||||
Description: "This is another example a upcoming message for a service!",
|
||||
ServiceId: 3,
|
||||
StartOn: time.Now().Add(15 * time.Minute),
|
||||
EndOn: time.Now().Add(2 * time.Hour),
|
||||
})
|
||||
m2.Create()
|
||||
}
|
||||
|
||||
// InsertLargeSampleData will create the example/dummy services for testing the Statup server
|
||||
func InsertLargeSampleData() error {
|
||||
insertSampleCore()
|
||||
InsertSampleData()
|
||||
insertSampleUsers()
|
||||
insertSampleCheckins()
|
||||
insertMessages()
|
||||
s6 := ReturnService(&types.Service{
|
||||
Name: "JSON Lint",
|
||||
Domain: "https://jsonlint.com",
|
||||
|
|
|
@ -17,6 +17,7 @@ package core
|
|||
|
||||
import (
|
||||
"github.com/hunterlong/statup/types"
|
||||
"github.com/hunterlong/statup/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
@ -26,7 +27,7 @@ func TestCreateUser(t *testing.T) {
|
|||
Username: "hunter",
|
||||
Password: "password123",
|
||||
Email: "test@email.com",
|
||||
Admin: true,
|
||||
Admin: utils.NullBool(true),
|
||||
})
|
||||
userId, err := user.Create()
|
||||
assert.Nil(t, err)
|
||||
|
@ -43,7 +44,7 @@ func TestSelectUser(t *testing.T) {
|
|||
user, err := SelectUser(1)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "info@betatude.com", user.Email)
|
||||
assert.True(t, user.Admin)
|
||||
assert.True(t, user.Admin.Bool)
|
||||
}
|
||||
|
||||
func TestSelectUsername(t *testing.T) {
|
||||
|
@ -51,7 +52,7 @@ func TestSelectUsername(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
assert.Equal(t, "test@email.com", user.Email)
|
||||
assert.Equal(t, int64(3), user.Id)
|
||||
assert.True(t, user.Admin)
|
||||
assert.True(t, user.Admin.Bool)
|
||||
}
|
||||
|
||||
func TestUpdateUser(t *testing.T) {
|
||||
|
@ -70,7 +71,7 @@ func TestCreateUser2(t *testing.T) {
|
|||
Username: "hunterlong",
|
||||
Password: "password123",
|
||||
Email: "user@email.com",
|
||||
Admin: true,
|
||||
Admin: utils.NullBool(true),
|
||||
})
|
||||
userId, err := user.Create()
|
||||
assert.Nil(t, err)
|
||||
|
@ -89,7 +90,7 @@ func TestAuthUser(t *testing.T) {
|
|||
assert.NotNil(t, user)
|
||||
assert.Equal(t, "user@email.com", user.Email)
|
||||
assert.Equal(t, int64(4), user.Id)
|
||||
assert.True(t, user.Admin)
|
||||
assert.True(t, user.Admin.Bool)
|
||||
}
|
||||
|
||||
func TestFailedAuthUser(t *testing.T) {
|
||||
|
|
|
@ -33,7 +33,7 @@ type Core struct {
|
|||
ApiKey string `gorm:"column:api_key" json:"-"`
|
||||
ApiSecret string `gorm:"column:api_secret" json:"-"`
|
||||
Style string `gorm:"not null;column:style" json:"style,omitempty"`
|
||||
Footer sql.NullString `gorm:"not null;column:footer" json:"footer"`
|
||||
Footer sql.NullString `gorm:"column:footer" json:"footer"`
|
||||
Domain string `gorm:"not null;column:domain" json:"domain"`
|
||||
Version string `gorm:"column:version" json:"version"`
|
||||
MigrationId int64 `gorm:"column:migration_id" json:"migration_id,omitempty"`
|
||||
|
|
|
@ -25,12 +25,12 @@ type Service struct {
|
|||
Id int64 `gorm:"primary_key;column:id" json:"id"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
Domain string `gorm:"column:domain" json:"domain"`
|
||||
Expected sql.NullString `gorm:"not null;column:expected" json:"expected"`
|
||||
Expected sql.NullString `gorm:"column:expected" json:"expected"`
|
||||
ExpectedStatus int `gorm:"default:200;column:expected_status" json:"expected_status"`
|
||||
Interval int `gorm:"default:30;column:check_interval" json:"check_interval"`
|
||||
Type string `gorm:"column:check_type" json:"type"`
|
||||
Method string `gorm:"column:method" json:"method"`
|
||||
PostData sql.NullString `gorm:"not null;column:post_data" json:"post_data"`
|
||||
PostData sql.NullString `gorm:"column:post_data" json:"post_data"`
|
||||
Port int `gorm:"not null;column:port" json:"port"`
|
||||
Timeout int `gorm:"default:30;column:timeout" json:"timeout"`
|
||||
Order int `gorm:"default:0;column:order_id" json:"order_id"`
|
||||
|
|
Loading…
Reference in New Issue