github.com/emmahsax/go-git-helper@v0.0.8-0.20240519163017-907b9de0fa52/internal/utils/utils_test.go (about)

     1  package utils
     2  
     3  import (
     4  	"errors"
     5  	"testing"
     6  )
     7  
     8  type MockLogger struct {
     9  	FatalCalled bool
    10  }
    11  
    12  func (m *MockLogger) Fatal(v ...interface{}) {
    13  	m.FatalCalled = true
    14  }
    15  
    16  func TestHandleError(t *testing.T) {
    17  	logger := &MockLogger{}
    18  
    19  	HandleError(errors.New("test error"), false, logger)
    20  
    21  	if !logger.FatalCalled {
    22  		t.Errorf("Expected Fatal to be called on logger")
    23  	}
    24  }