Tests validate virtual host validator.
(t *testing.T)
| 153 | |
| 154 | // Tests validate virtual host validator. |
| 155 | func TestIsVirtualHostSupported(t *testing.T) { |
| 156 | testCases := []struct { |
| 157 | url string |
| 158 | bucket string |
| 159 | // Expeceted result. |
| 160 | result bool |
| 161 | }{ |
| 162 | {"https://s3.amazonaws.com", "my-bucket", true}, |
| 163 | {"https://s3.cn-north-1.amazonaws.com.cn", "my-bucket", true}, |
| 164 | {"https://s3.amazonaws.com", "my-bucket.", false}, |
| 165 | {"https://amazons3.amazonaws.com", "my-bucket.", false}, |
| 166 | {"https://storage.googleapis.com/", "my-bucket", true}, |
| 167 | {"https://mystorage.googleapis.com/", "my-bucket", false}, |
| 168 | } |
| 169 | |
| 170 | for i, testCase := range testCases { |
| 171 | u, err := url.Parse(testCase.url) |
| 172 | if err != nil { |
| 173 | t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err) |
| 174 | } |
| 175 | result := IsVirtualHostSupported(*u, testCase.bucket) |
| 176 | if testCase.result != result { |
| 177 | t.Errorf("Test %d: Expected isVirtualHostSupported to be '%v' for input url \"%s\" and bucket \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, testCase.bucket, result) |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // Tests validate S3 Outposts endpoint detector. |
| 183 | func TestIsAmazonOutpostsEndpoint(t *testing.T) { |
nothing calls this directly
no test coverage detected