-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
utils.go
47 lines (38 loc) · 900 Bytes
/
utils.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
44
45
46
47
package testza
import (
"fmt"
"path/filepath"
"runtime"
"github.com/pterm/pterm"
)
type testRunner interface {
Error(args ...any)
}
// TestingPackageWithFailFunctions contains every function that fails a test in testing.T.
type TestingPackageWithFailFunctions interface {
Error(args ...any)
Errorf(format string, args ...any)
Fail()
FailNow()
Fatal(args ...any)
Fatalf(format string, args ...any)
}
type helper interface {
Helper()
}
var green = pterm.NewStyle(pterm.Bold, pterm.FgLightGreen).Sprint
var red = pterm.NewStyle(pterm.Bold, pterm.FgLightRed).Sprint
var highlight = red
func generateMsg(msg []any, addon ...any) (out string) {
for _, s := range addon {
out += fmt.Sprint(s)
}
for _, s := range msg {
out += fmt.Sprint(s)
}
return
}
func getCurrentScriptDirectory() string {
_, scriptPath, _, _ := runtime.Caller(2)
return filepath.Join(scriptPath, "..")
}