osutil_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. }
  53. func TestCurrentUsername(t *testing.T) {
  54. // Make sure it does not blow up
  55. CurrentUsername()
  56. }