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.

helper_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package storage
  4. import (
  5. "bytes"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func Test_discardStorage(t *testing.T) {
  10. tests := []discardStorage{
  11. uninitializedStorage,
  12. discardStorage("empty"),
  13. }
  14. for _, tt := range tests {
  15. t.Run(string(tt), func(t *testing.T) {
  16. {
  17. got, err := tt.Open("path")
  18. assert.Nil(t, got)
  19. assert.Error(t, err, string(tt))
  20. }
  21. {
  22. got, err := tt.Save("path", bytes.NewReader([]byte{0}), 1)
  23. assert.Equal(t, int64(0), got)
  24. assert.Error(t, err, string(tt))
  25. }
  26. {
  27. got, err := tt.Stat("path")
  28. assert.Nil(t, got)
  29. assert.Error(t, err, string(tt))
  30. }
  31. {
  32. err := tt.Delete("path")
  33. assert.Error(t, err, string(tt))
  34. }
  35. {
  36. got, err := tt.URL("path", "name")
  37. assert.Nil(t, got)
  38. assert.Errorf(t, err, string(tt))
  39. }
  40. {
  41. err := tt.IterateObjects("", func(_ string, _ Object) error { return nil })
  42. assert.Error(t, err, string(tt))
  43. }
  44. })
  45. }
  46. }