-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
69 lines (56 loc) · 1.52 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
_ "embed"
"fmt"
"log"
"os"
"time"
"github.com/launchdarkly/sse-contract-tests/framework"
"github.com/launchdarkly/sse-contract-tests/framework/harness"
"github.com/launchdarkly/sse-contract-tests/framework/ldtest"
"github.com/launchdarkly/sse-contract-tests/ssetests"
)
const defaultPort = 8111
const statusQueryTimeout = time.Second * 10
func main() {
fmt.Print("sse-contract-tests 2.3.0") // x-release-please-version
var params commandParams
if !params.Read(os.Args) {
os.Exit(1)
}
mainDebugLogger := framework.NullLogger()
if params.debugAll {
mainDebugLogger = log.New(os.Stdout, "", log.LstdFlags)
}
harness, err := harness.NewTestHarness(
params.serviceURL,
params.host,
params.port,
statusQueryTimeout,
mainDebugLogger,
os.Stdout,
)
if err != nil {
fmt.Fprintf(os.Stderr, "Test service error: %s\n", err)
os.Exit(1)
}
fmt.Println()
ldtest.PrintFilterDescription(params.filters, ssetests.AllCapabilities, harness.TestServiceInfo().Capabilities)
fmt.Println("Running test suite")
testLogger := ldtest.ConsoleTestLogger{
DebugOutputOnFailure: params.debug || params.debugAll,
DebugOutputOnSuccess: params.debugAll,
}
results := ssetests.RunTestSuite(harness, params.filters.Match, testLogger)
fmt.Println()
ldtest.PrintResults(results)
if params.stopServiceAtEnd {
fmt.Println("Stopping test service")
if err := harness.StopService(); err != nil {
fmt.Fprintf(os.Stderr, "Failed to stop test service: %s\n", err)
}
}
if !results.OK() {
os.Exit(1)
}
}