mirror of https://github.com/statping/statping
tests
parent
8aa2dba41c
commit
006f02d4d4
|
@ -18,8 +18,9 @@ package notifier
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
c "github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/source"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -84,7 +85,11 @@ var example = &ExampleNotifier{&Notification{
|
|||
|
||||
// init will be ran when Statping is loaded, AddNotifier will add the notifier instance to the system
|
||||
func init() {
|
||||
c.AttachNotifiers()
|
||||
dir = utils.Directory
|
||||
source.Assets()
|
||||
utils.InitLogs()
|
||||
injectDatabase()
|
||||
AddNotifiers(example)
|
||||
}
|
||||
|
||||
// Send is the main function to hold your notifier functionality
|
||||
|
@ -227,7 +232,9 @@ func ExampleNotification_OnSuccess() {
|
|||
msg := fmt.Sprintf("this is a successful message as a string passing into AddQueue function")
|
||||
example.AddQueue("example", msg)
|
||||
fmt.Println(len(example.Queue))
|
||||
// Output: 1
|
||||
// Output:
|
||||
// Notifier 'Example' added new item (example) to the queue. (1 queued)
|
||||
// 1
|
||||
}
|
||||
|
||||
// Add a new message into the queue OnSuccess
|
||||
|
@ -253,7 +260,7 @@ func ExampleOnTest() {
|
|||
func ExampleNotification_CanTest() {
|
||||
testable := example.CanTest()
|
||||
fmt.Print(testable)
|
||||
// Output: false
|
||||
// Output: true
|
||||
}
|
||||
|
||||
// Add any type of interface to the AddQueue function to be ran in the queue
|
||||
|
@ -262,7 +269,9 @@ func ExampleNotification_AddQueue() {
|
|||
example.AddQueue("example", msg)
|
||||
queue := example.Queue
|
||||
fmt.Printf("Example has %v items in the queue", len(queue))
|
||||
// Output: Example has 2 items in the queue
|
||||
// Output:
|
||||
// Notifier 'Example' added new item (example) to the queue. (2 queued)
|
||||
// Example has 2 items in the queue
|
||||
}
|
||||
|
||||
// The Send method will run the main functionality of your notifier
|
||||
|
|
|
@ -17,7 +17,6 @@ package notifier
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/source"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/jinzhu/gorm"
|
||||
|
@ -56,13 +55,6 @@ var core = &types.Core{
|
|||
Name: "testing notifiers",
|
||||
}
|
||||
|
||||
func init() {
|
||||
dir = utils.Directory
|
||||
source.Assets()
|
||||
utils.InitLogs()
|
||||
injectDatabase()
|
||||
}
|
||||
|
||||
func injectDatabase() {
|
||||
utils.DeleteFile(dir + "/statup.db")
|
||||
db, _ = gorm.Open("sqlite3", dir+"/statup.db")
|
||||
|
|
Loading…
Reference in New Issue