pull/78/head v0.70
Hunter Long 2018-09-28 09:17:21 -07:00
parent 91ad727f50
commit 1f0169a746
4 changed files with 97 additions and 5 deletions

View File

@ -1,4 +1,4 @@
VERSION=0.69
VERSION=0.70
BINARY_NAME=statup
GOPATH:=$(GOPATH)
GOCMD=go

View File

@ -1,8 +1,6 @@
// Package notifiers holds all the notifiers for Statup, which also includes
// user created notifiers that have been accepted in a Push Request. Read the
// Statup notifier wiki at: https://github.com/hunterlong/statup/wiki
//
// To see a full example of a notifier with all events, visit Statup's
// user created notifiers that have been accepted in a Push Request. Read the wiki
// to see a full example of a notifier with all events, visit Statup's
// notifier example code: https://github.com/hunterlong/statup/wiki/Notifier-Example
//
// More info on: https://github.com/hunterlong/statup

View File

@ -16,6 +16,7 @@
package plugin
import (
"github.com/hunterlong/statup/core/notifier"
"github.com/jinzhu/gorm"
"net/http"
)
@ -32,6 +33,45 @@ import (
// work even if there's an update or addition.
//
type PluginObject struct{}
var (
AllPlugins []*PluginObject
)
func Add(p Pluginer) *PluginObject {
return &PluginObject{}
}
func (p *PluginObject) AddRoute(s string, i string, f http.HandlerFunc) {
}
type Pluginer interface {
Select() *PluginObject
}
type Databaser interface {
StatupDatabase(*gorm.DB)
}
type Router interface {
AddRoute(string, string, http.HandlerFunc) error
}
type Notifier interface {
notifier.Notifier
notifier.BasicEvents
}
type AdvancedNotifier interface {
notifier.Notifier
notifier.BasicEvents
notifier.UserEvents
notifier.CoreEvents
notifier.NotifierEvents
}
var (
DB *gorm.DB
)

54
plugin/main_test.go Normal file
View File

@ -0,0 +1,54 @@
// Statup
// Copyright (C) 2018. Hunter Long and the project contributors
// Written by Hunter Long <info@socialeck.com> and the project contributors
//
// https://github.com/hunterlong/statup
//
// The licenses for most software and other practical works are designed
// to take away your freedom to share and change the works. By contrast,
// the GNU General Public License is intended to guarantee your freedom to
// share and change all versions of a program--to make sure it remains free
// software for all its users.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package plugin
import (
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
var (
database *gorm.DB
example *PluginObject
)
func (p *PluginObject) StatupDatabase(db *gorm.DB) {
database = db
}
func (p *PluginObject) Select() *PluginObject {
return p
}
func setupHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
}
func TestAdd(t *testing.T) {
err := Add(example)
assert.NotNil(t, err)
}
func TestSelect(t *testing.T) {
err := example.Select()
assert.Nil(t, err)
}
func TestAddRoute(t *testing.T) {
example.AddRoute("/plugin_example", "GET", setupHandler)
}