-
Notifications
You must be signed in to change notification settings - Fork 9
/
entrypoint.go
47 lines (36 loc) · 951 Bytes
/
entrypoint.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
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package testboot
import (
"flag"
"log"
"os"
"time"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)
type TestData struct {
Request *TestRequest
}
func BootstrapTest(testTimeout time.Duration, debug bool) TestData {
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.Lshortfile)
flag.Parse()
go func() {
time.Sleep(testTimeout)
log.Fatal("test timed out after", testTimeout)
}()
reqBytes, err := os.ReadFile("/" + TestRequestPath)
if err != nil {
log.Fatal(err)
}
req := &TestRequest{}
if err := proto.Unmarshal(reqBytes, req); err != nil {
log.Fatal(err)
}
if debug {
log.Println(prototext.Format(req))
log.Println("initialization complete")
}
return TestData{Request: req}
}