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