/
main.go
43 lines (41 loc) · 1.32 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"github.com/snikch/goodman/hooks"
"github.com/snikch/goodman/transaction"
)
func main() {
// This must be compiled beforehand and given to dredd as parameter, in the meantime the server should be running
h := hooks.NewHooks()
server := hooks.NewServer(hooks.NewHooksRunner(h))
h.BeforeAll(func(t []*transaction.Transaction) {
fmt.Println("Sleep 5 seconds before all modification")
})
h.BeforeEach(func(t *transaction.Transaction) {
fmt.Println("before each modification")
})
h.Before("/version > GET", func(t *transaction.Transaction) {
fmt.Println("before version TEST")
})
h.Before("/node_version > GET", func(t *transaction.Transaction) {
fmt.Println("before node_version TEST")
})
h.BeforeEachValidation(func(t *transaction.Transaction) {
fmt.Println("before each validation modification")
})
h.BeforeValidation("/node_version > GET", func(t *transaction.Transaction) {
fmt.Println("before validation node_version TEST")
})
h.After("/node_version > GET", func(t *transaction.Transaction) {
fmt.Println("after node_version TEST")
})
h.AfterEach(func(t *transaction.Transaction) {
fmt.Println("after each modification")
})
h.AfterAll(func(t []*transaction.Transaction) {
fmt.Println("after all modification")
})
server.Serve()
defer server.Listener.Close()
fmt.Print(h)
}