carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package lease
2
3import "testing"
4
5func TestStagingObjectURL(t *testing.T) {
6 cases := []struct {
7 name, endpoint, bucket, key, want string
8 }{
9 {"virtual-hosted", "", "data-uk", "moves/h/op/a b+c", "https://data-uk.s3.eu-west-2.amazonaws.com/moves/h/op/a%20b%2Bc"},
10 {"dotted bucket goes path-style", "", "data.uk", "k", "https://s3.eu-west-2.amazonaws.com/data.uk/k"},
11 {"endpoint override is path-style", "https://store.example:9000", "data-uk", "a/é", "https://store.example:9000/data-uk/a/%C3%A9"},
12 }
13 for _, c := range cases {
14 m := &StagingMirror{endpoint: c.endpoint, region: "eu-west-2"}
15 u, err := m.objectURL(c.bucket, c.key)
16 if err != nil || u.String() != c.want {
17 t.Errorf("%s: got %v %v, want %s", c.name, u, err, c.want)
18 }
19 }
20}
21