-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
notifier.go
39 lines (31 loc) · 800 Bytes
/
notifier.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
package mocha
import (
"fmt"
)
// T is based on testing.T and allow mocha components to log information and errors.
type T interface {
Helper()
Logf(string, ...any)
Errorf(string, ...any)
FailNow()
}
// ConsoleNotifier implements core.T outputting logs to the stdout.
type ConsoleNotifier struct {
}
func (n *ConsoleNotifier) Logf(format string, args ...any) {
fmt.Printf(format, args...)
}
func (n *ConsoleNotifier) Errorf(format string, args ...any) {
n.Logf(format, args...)
}
// FailNow do nothing.
func (n *ConsoleNotifier) FailNow() {
}
// Helper do nothing.
func (n *ConsoleNotifier) Helper() {
}
// NewConsoleNotifier returns a core.T implementation that logs to the stdout.
// FailNow() and Helper() will do nothing.
func NewConsoleNotifier() T {
return &ConsoleNotifier{}
}