osutil_test.go 602 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2020 The Gogs 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 osutil
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestIsFile(t *testing.T) {
  10. tests := []struct {
  11. path string
  12. expVal bool
  13. }{
  14. {
  15. path: "osutil.go",
  16. expVal: true,
  17. }, {
  18. path: "../osutil",
  19. expVal: false,
  20. }, {
  21. path: "not_found",
  22. expVal: false,
  23. },
  24. }
  25. for _, test := range tests {
  26. t.Run("", func(t *testing.T) {
  27. assert.Equal(t, test.expVal, IsFile(test.path))
  28. })
  29. }
  30. }