-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_flags_test.go
77 lines (70 loc) · 1.52 KB
/
process_flags_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
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
70
71
72
73
74
75
76
77
package main
import (
"context"
"errors"
"testing"
)
func TestProcessFlags(t *testing.T) {
required_ok := []string{
"-bucket", "bucket",
"glob1", "glob2", "glob3",
}
tests := []struct {
optional []string
required []string
expect func(opts *Options, err error)
}{
/*
{
required:
expect: func(opts *Options, err error) {
},
},
*/
{
optional: []string{"-checksum", "MD5"},
required: required_ok,
expect: func(opts *Options, err error) {
if !errors.Is(err, errBadChecksum) {
t.Errorf("expected errBadChecksum, got %v", err)
}
},
},
{
optional: []string{"-part-size", "1MiB"},
required: required_ok,
expect: func(opts *Options, err error) {
if !errors.Is(err, errBadPartSize) {
t.Errorf("expected errBadPartSize, got %v", err)
}
},
},
{
required: required_ok,
expect: func(opts *Options, err error) {
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if opts == nil {
t.Errorf("nil options returned")
} else {
if opts.MaxPartID != DefaultMaxPartID {
t.Errorf("expected default MaxPartID %d, got %d",
DefaultMaxPartID, opts.MaxPartID)
}
if opts.bucket != "bucket" {
t.Errorf("expected -bucket bucket: %s", opts.bucket)
}
if len(opts.globs) != 3 {
t.Errorf("expected 3 globs: %s", opts.globs)
}
}
},
},
}
for _, tst := range tests {
opts, err := processFlags(
context.Background(), append(tst.optional, tst.required...))
tst.expect(opts, err)
}
}