error_test.go 599 B

1234567891011121314151617181920212223242526272829
  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. "os"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. "gogs.io/gogs/internal/errutil"
  10. )
  11. func TestError_NotFound(t *testing.T) {
  12. tests := []struct {
  13. err error
  14. expVal bool
  15. }{
  16. {err: os.ErrNotExist, expVal: true},
  17. {err: os.ErrClosed, expVal: false},
  18. }
  19. for _, test := range tests {
  20. t.Run("", func(t *testing.T) {
  21. assert.Equal(t, test.expVal, errutil.IsNotFound(NewError(test.err)))
  22. })
  23. }
  24. }