21 lines
421 B
Go
21 lines
421 B
Go
|
package errorhandler
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestCheck(t *testing.T) {
|
||
|
text := "text before error"
|
||
|
err := "test error"
|
||
|
|
||
|
expected := fmt.Errorf("%s, error is:\n\t-> %s", text, err)
|
||
|
result := FormatError(text, errors.New(err))
|
||
|
fmt.Println(result, expected)
|
||
|
|
||
|
if result.Error() != expected.Error() {
|
||
|
t.Fatalf("expected (%s) is different from result (%s)", expected.Error(), result.Error())
|
||
|
}
|
||
|
}
|