1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

cleanup integration test code

This commit is contained in:
Jesse Duffield
2023-02-26 11:49:15 +11:00
parent 8b5d59c238
commit f7e8b2dd71
70 changed files with 322 additions and 272 deletions

40
pkg/fakes/log.go Normal file
View File

@ -0,0 +1,40 @@
package fakes
import (
"fmt"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
var _ logrus.FieldLogger = &FakeFieldLogger{}
// for now we're just tracking calls to the Error and Errorf methods
type FakeFieldLogger struct {
loggedErrors []string
*logrus.Entry
}
func (self *FakeFieldLogger) Error(args ...interface{}) {
if len(args) != 1 {
panic("Expected exactly one argument to FakeFieldLogger.Error")
}
switch arg := args[0].(type) {
case error:
self.loggedErrors = append(self.loggedErrors, arg.Error())
case string:
self.loggedErrors = append(self.loggedErrors, arg)
}
}
func (self *FakeFieldLogger) Errorf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
self.loggedErrors = append(self.loggedErrors, msg)
}
func (self *FakeFieldLogger) AssertErrors(t *testing.T, expectedErrors []string) {
t.Helper()
assert.EqualValues(t, expectedErrors, self.loggedErrors)
}