From 50789d6000e17b899ba25fd96b387460cdd3f1dd Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Thu, 8 Oct 2020 17:57:25 +0300 Subject: [PATCH] Covered errors to 100% --- utils/errors_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/utils/errors_test.go b/utils/errors_test.go index f7312143b..71d9d6429 100644 --- a/utils/errors_test.go +++ b/utils/errors_test.go @@ -208,6 +208,10 @@ func TestIsNetworkError(t *testing.T) { if !IsNetworkError(err) { t.Errorf("syscall.ECONNRESET should be consider a network error") } + err = &net.DNSError{Err: "DNSError"} + if !IsNetworkError(err) { + t.Errorf("DNSError should be consider a network error") + } err = fmt.Errorf("NOT_FOUND") if IsNetworkError(err) { t.Errorf("%s error should not be consider a network error", err) @@ -238,6 +242,27 @@ func TestNewErrChargerS(t *testing.T) { } } +func TestNewErrStatS(t *testing.T) { + expected := "STATS_ERROR:NOT_FOUND" + if rcv := NewErrStatS(ErrNotFound); rcv.Error() != expected { + t.Errorf("Expecetd %+q, receiveed %+q", expected, rcv.Error()) + } +} + +func TestNewErrCDRS(t *testing.T) { + expected := "CDRS_ERROR:NOT_FOUND" + if rcv := NewErrCDRS(ErrNotFound); rcv.Error() != expected { + t.Errorf("Expected %+q, received %+q", expected, rcv.Error()) + } +} + +func TestNewErrThresholdS(t *testing.T) { + expected := "THRESHOLDS_ERROR:NOT_FOUND" + if rcv := NewErrThresholdS(ErrNotFound); rcv.Error() != expected { + t.Errorf("Expected %+q, received %+q", expected, rcv.Error()) + } +} + func TestNewSTIRError(t *testing.T) { expected := `*stir_authenticate: wrong header` if rcv := NewSTIRError("wrong header"); rcv.Error() != expected {