mirror of
https://github.com/adnanh/webhook.git
synced 2026-07-26 17:10:45 +08:00
Merge pull request #46 from moorereason/testing
Add testing framework for main webhook app
This commit is contained in:
+2
-5
@@ -42,7 +42,7 @@ var (
|
||||
hooks hook.Hooks
|
||||
)
|
||||
|
||||
func init() {
|
||||
func main() {
|
||||
hooks = hook.Hooks{}
|
||||
|
||||
flag.Parse()
|
||||
@@ -78,9 +78,7 @@ func init() {
|
||||
log.Printf("\t> %s\n", hook.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if *hotReload {
|
||||
// set up file watcher
|
||||
log.Printf("setting up file watcher for %s\n", *hooksFilePath)
|
||||
@@ -103,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
l := negroni.NewLogger()
|
||||
l.Logger = log.New(os.Stdout, "[webhook] ", log.Ldate|log.Ltime)
|
||||
l.Logger = log.New(os.Stderr, "[webhook] ", log.Ldate|log.Ltime)
|
||||
|
||||
negroniRecovery := &negroni.Recovery{
|
||||
Logger: l.Logger,
|
||||
@@ -224,7 +222,6 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// if none of the hooks got triggered
|
||||
log.Printf("%s got matched (%d time(s)), but didn't get triggered because the trigger rules were not satisfied\n", matchedHooks[0].ID, len(matchedHooks))
|
||||
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "Hook rules were not satisfied.")
|
||||
} else {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
Reference in New Issue
Block a user