package bucket import ( "testing" ) func TestBucket_Validate(t *testing.T) { var got error got = Bucket("http://api.url").Validate() if got == nil { t.Errorf("Bucket.Validate() = %v; want non-nil", got) } got = Bucket("http://api.url/").Validate() if got != nil { t.Errorf("Bucket.Validate() = %v; want nil", got) } got = Bucket("http://api.url/bucket").Validate() if got == nil { t.Errorf("Bucket.Validate() = %v; want non-nil", got) } got = Bucket("http://api.url/bucket/").Validate() if got != nil { t.Errorf("Bucket.Validate() = %v; want nil", got) } got = Bucket("http://api.url/bucket/path/").Validate() if got != nil { t.Errorf("Bucket.Validate() = %v; want nil", got) } } func TestBucket_URL(t *testing.T) { var got, want string var b Bucket b = Bucket("http://api.url/bucket/") got = b.URL(Photo("/photo/hello")).String() want = "http://api.url/bucket/photo/hello" if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } got = b.URL(Preview("preview/hello")).String() want = "http://api.url/bucket/preview/hello" if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } got = b.URL(NewList("photo/", 1000, "name")).String() want = "http://api.url/bucket/?delimiter=&encoding-type=url&list-type=2&max-keys=1000&metadata=true&prefix=photo%2F&start-after=name" if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } b = Bucket("http://bucket.api.url") got = b.URL(Photo("/photo/hello")).String() want = "http://bucket.api.url/photo/hello" if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } got = b.URL(Preview("preview/hello")).String() want = "http://bucket.api.url/preview/hello" if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } got = b.URL(NewList("photo/", 1000, "name")).String() want = "http://bucket.api.url" + NewList("photo/", 1000, "name").Path().String() if got != want { t.Errorf("Bucket.URL(Photo) = %v; want %v", got, want) } }