-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
51 lines (43 loc) · 1.05 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
44
45
46
47
48
49
50
51
package main
import (
"errors"
"flag"
"fmt"
"github.com/grafana/oats/yaml"
"github.com/onsi/gomega"
"log/slog"
"time"
)
func main() {
err := run()
if err != nil {
panic(err)
}
}
func run() error {
lgtmVersion := flag.String("lgtm-version", "latest", "version of https://github.com/grafana/docker-otel-lgtm")
timeout := flag.Duration("timeout", 30*time.Second, "timeout for the test case")
manualDebug := flag.Bool("manual-debug", false, "debug mode")
flag.Parse()
if flag.NArg() != 1 {
return errors.New("you must pass a path to the test case yaml file")
}
gomega.RegisterFailHandler(func(message string, callerSkip ...int) {
panic(message)
})
cases, base := yaml.ReadTestCases(flag.Arg(0))
if len(cases) == 0 {
return fmt.Errorf("no cases found in %s", base)
}
for _, testCase := range cases {
slog.Info("test case found", "test", testCase.Name)
}
for _, c := range cases {
c.LgtmVersion = *lgtmVersion
c.Timeout = *timeout
c.ManualDebug = *manualDebug
yaml.RunTestCase(c)
}
slog.Info("all test cases passed")
return nil
}