osutil_test.go 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. }
  31. func TestIsExist(t *testing.T) {
  32. tests := []struct {
  33. path string
  34. expVal bool
  35. }{
  36. {
  37. path: "osutil.go",
  38. expVal: true,
  39. }, {
  40. path: "../osutil",
  41. expVal: true,
  42. }, {
  43. path: "not_found",
  44. expVal: false,
  45. },
  46. }
  47. for _, test := range tests {
  48. t.Run("", func(t *testing.T) {
  49. assert.Equal(t, test.expVal, IsExist(test.path))
  50. })
  51. }
  52. }