summaryrefslogtreecommitdiff
path: root/errors/debug_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-05 17:58:23 +0300
committerGitHub <[email protected]>2020-11-05 17:58:23 +0300
commit9fbe7726dd55cfedda724b7644e1b6bf7c1a6cb4 (patch)
treef2bf9b97d38103de51e2d140aa76666f9c6341c8 /errors/debug_test.go
parentedc45b3e24afdb5e56e74ffbbbd50e0e3b04922b (diff)
parent73da7300fcc9b8b22faa1c91fc1faff22ab944ff (diff)
Merge pull request #388 from spiral/enhancement/testsv2.0.0-alpha15
Tests for the new plugins
Diffstat (limited to 'errors/debug_test.go')
-rwxr-xr-xerrors/debug_test.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/errors/debug_test.go b/errors/debug_test.go
deleted file mode 100755
index bc866bc8..00000000
--- a/errors/debug_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// +build debug
-
-package errors
-
-import (
- "fmt"
- "regexp"
- "strings"
- "testing"
-)
-
-var errorLines = strings.Split(strings.TrimSpace(`
- .*/errors/debug_test.go:\d+: github.com/ValeryPiashchynski/errors.func1:
- .*/errors/debug_test.go:\d+: ...T.func2:
- .*/errors/debug_test.go:\d+: ...func3:
- .*/errors/debug_test.go:\d+: ...func4: func2 invoke func3: Network error:
- func4 operation: error in action
-`), "\n")
-
-var errorLineREs = make([]*regexp.Regexp, len(errorLines))
-
-func init() {
- for i, s := range errorLines {
- errorLineREs[i] = regexp.MustCompile(fmt.Sprintf("^%s", s))
- }
-}
-
-func TestsDebug(t *testing.T) {
- got := printErr(t, func1())
- lines := strings.Split(got, "\n")
- for i, re := range errorLineREs {
- if i >= len(lines) {
- // Handled by line number check.
- break
- }
- if !re.MatchString(lines[i]) {
- t.Errorf("error does not match at line %v, got:\n\t%q\nwant:\n\t%q", i, lines[i], re)
- }
- }
- if got, want := len(lines), len(errorLines); got != want {
- t.Errorf("got %v lines of errors, want %v", got, want)
- }
-}
-
-type T struct{}
-
-func printErr(t *testing.T, err error) string {
- return err.Error()
-}
-
-func func1() error {
- var t T
- return t.func2()
-}
-
-func (T) func2() error {
- o := Op("func2 invoke func3")
- return E(o, func3())
-}
-
-func func3() error {
- return func4()
-}
-
-func func4() error {
- o := Op("func4 operation")
- return E(o, Network, Str("error in action"))
-}
-
-///Users/0xdev/Projects/repo/errors/debug_test.go:53: github.com/ValeryPiashchynski/errors.func1:
-///Users/0xdev/Projects/repo/errors/debug_test.go:58: ...T.func2:
-///Users/0xdev/Projects/repo/errors/debug_test.go:62: ...func3:
-///Users/0xdev/Projects/repo/errors/debug_test.go:67: ...func4: func2 invoke func3: Network error:
-//func4 operation: error in action