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.

27 lines
698 B

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repofiles
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestCleanUploadFileName(t *testing.T) {
  10. t.Run("Clean regular file", func(t *testing.T) {
  11. name := "this/is/test"
  12. cleanName := CleanUploadFileName(name)
  13. expectedCleanName := name
  14. assert.EqualValues(t, expectedCleanName, cleanName)
  15. })
  16. t.Run("Clean a .git path", func(t *testing.T) {
  17. name := "this/is/test/.git"
  18. cleanName := CleanUploadFileName(name)
  19. expectedCleanName := ""
  20. assert.EqualValues(t, expectedCleanName, cleanName)
  21. })
  22. }