-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy paths3uri_test.go
More file actions
43 lines (38 loc) · 942 Bytes
/
Copy paths3uri_test.go
File metadata and controls
43 lines (38 loc) · 942 Bytes
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
package main
import "testing"
func TestS3Uri(t *testing.T) {
cases := []struct {
input string
suffix string
expected string
}{
{"s3://bucket/a", "b", "a/b"},
{"s3://bucket/a", "/b", "a/b"},
{"s3://bucket/a/", "b", "a/b"},
{"s3://bucket/a/", "/b", "a/b"},
{"s3://bucket", "b", "b"},
{"s3://bucket/", "b", "b"},
}
for _, c := range cases {
var s S3Uri
if err := s.UnmarshalText([]byte(c.input)); err != nil {
t.Errorf("UnmarshalText(%q) error: %v", c.input, err)
continue
}
if actual := s.GetKey(c.suffix); actual != c.expected {
t.Errorf("GetKey(%q) on %q: expected %q, got %q", c.suffix, c.input, c.expected, actual)
}
}
}
func TestS3UriErrors(t *testing.T) {
cases := []string{
"http://bucket/a",
"s3://",
}
for _, input := range cases {
var s S3Uri
if err := s.UnmarshalText([]byte(input)); err == nil {
t.Errorf("UnmarshalText(%q) expected error, got nil", input)
}
}
}