errorhandler/main_test.go

21 lines
421 B
Go
Raw Permalink Normal View History

2023-03-21 18:21:57 +00:00
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())
}
}