checkConnection returns true if a connection could be made, false otherwise.
()
| 225 | |
| 226 | // checkConnection returns true if a connection could be made, false otherwise. |
| 227 | func checkConnection() bool { |
| 228 | os.Setenv("AWS_ACCESS_KEY_ID", "AKIAIOSFODNN7EXAMPLE") |
| 229 | os.Setenv("AWS_SECRET_ACCESS_KEY", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") |
| 230 | // No S3ForcePathStyle required because we're not accessing a specific bucket here. |
| 231 | sess, err := session.NewSession(aws.NewConfig().WithRegion(endpoints.UsEast1RegionID).WithEndpoint(customEndpoint)) |
| 232 | if err != nil { |
| 233 | log.Printf("An error occurred during testing the connection to the server: %v\n", err) |
| 234 | return false |
| 235 | } |
| 236 | svc := awss3.New(sess) |
| 237 | |
| 238 | _, err = svc.ListBuckets(&awss3.ListBucketsInput{}) |
| 239 | if err != nil { |
| 240 | log.Printf("An error occurred during testing the connection to the server: %v\n", err) |
| 241 | return false |
| 242 | } |
| 243 | |
| 244 | return true |
| 245 | } |
| 246 | |
| 247 | func createClient(t *testing.T, codec encoding.Codec) oss.Client { |
| 248 | // os.Setenv("AWS_ACCESS_KEY_ID", "AKIAIOSFODNN7EXAMPLE") |
no outgoing calls
no test coverage detected