integration.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Package integration performs initialization and validation for integration
  2. // tests.
  3. package integration
  4. import (
  5. "crypto/rand"
  6. "fmt"
  7. "io"
  8. "os"
  9. "github.com/aws/aws-sdk-go/aws"
  10. "github.com/aws/aws-sdk-go/aws/defaults"
  11. )
  12. // Imported is a marker to ensure that this package's init() function gets
  13. // executed.
  14. //
  15. // To use this package, import it and add:
  16. //
  17. // var _ = integration.Imported
  18. const Imported = true
  19. func init() {
  20. if os.Getenv("DEBUG") != "" {
  21. defaults.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebug)
  22. }
  23. if os.Getenv("DEBUG_SIGNING") != "" {
  24. defaults.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebugWithSigning)
  25. }
  26. if os.Getenv("DEBUG_BODY") != "" {
  27. defaults.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebugWithSigning | aws.LogDebugWithHTTPBody)
  28. }
  29. if aws.StringValue(defaults.DefaultConfig.Region) == "" {
  30. panic("AWS_REGION must be configured to run integration tests")
  31. }
  32. }
  33. // UniqueID returns a unique UUID-like identifier for use in generating
  34. // resources for integration tests.
  35. func UniqueID() string {
  36. uuid := make([]byte, 16)
  37. io.ReadFull(rand.Reader, uuid)
  38. return fmt.Sprintf("%x", uuid)
  39. }