You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
909 B

  1. package s3api
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestRemoveDuplicateSlashes(t *testing.T) {
  7. tests := []struct {
  8. name string
  9. path string
  10. expectedResult string
  11. }{
  12. {
  13. name: "empty",
  14. path: "",
  15. expectedResult: "",
  16. },
  17. {
  18. name: "slash",
  19. path: "/",
  20. expectedResult: "/",
  21. },
  22. {
  23. name: "object",
  24. path: "object",
  25. expectedResult: "object",
  26. },
  27. {
  28. name: "correct path",
  29. path: "/path/to/object",
  30. expectedResult: "/path/to/object",
  31. },
  32. {
  33. name: "path with duplicates",
  34. path: "///path//to/object//",
  35. expectedResult: "/path/to/object/",
  36. },
  37. }
  38. for _, tst := range tests {
  39. t.Run(tst.name, func(t *testing.T) {
  40. obj := removeDuplicateSlashes(tst.path)
  41. assert.Equal(t, tst.expectedResult, obj)
  42. })
  43. }
  44. }