-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_test.go
44 lines (35 loc) · 875 Bytes
/
base_test.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
package aws
import (
"context"
"flag"
"fmt"
"testing"
"github.com/d2jvkpn/gotk"
)
var (
testContext context.Context = context.Background()
testConfig *S3Config
testFlag *flag.FlagSet
testS3Client *S3Client
)
// default config: wk_config/aws_test.yaml
func TestMain(m *testing.M) {
var (
configFile string
field string
err error
)
testFlag = flag.NewFlagSet("testFlag", flag.ExitOnError)
flag.Parse() // must do
testFlag.StringVar(&configFile, "config", "configs/aws_test.yaml", "config filepath")
testFlag.StringVar(&field, "field", "aws_s3", "aws s3 field in config")
testFlag.Parse(flag.Args())
if configFile, err = gotk.RootFile(configFile); err != nil {
panic(err)
}
fmt.Printf("~~~ config %s::%s\n", configFile, field)
if testS3Client, err = NewS3Client(configFile, field); err != nil {
panic(err)
}
m.Run()
}