s3storage_test.go 708 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package storage
  2. import (
  3. "testing"
  4. )
  5. // TestS3Storage_protocol tests the protocol() method returns correct values based on insecure flag
  6. func TestS3Storage_protocol(t *testing.T) {
  7. tests := []struct {
  8. name string
  9. insecure bool
  10. want string
  11. }{
  12. {
  13. name: "secure connection returns HTTPS",
  14. insecure: false,
  15. want: "HTTPS",
  16. },
  17. {
  18. name: "insecure connection returns HTTP",
  19. insecure: true,
  20. want: "HTTP",
  21. },
  22. }
  23. for _, tt := range tests {
  24. t.Run(tt.name, func(t *testing.T) {
  25. s3 := &S3Storage{
  26. insecure: tt.insecure,
  27. }
  28. got := s3.protocol()
  29. if got != tt.want {
  30. t.Errorf("S3Storage.protocol() = %v, want %v", got, tt.want)
  31. }
  32. })
  33. }
  34. }