1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/i18n/i18n_test.go

44 lines
719 B
Go
Raw Normal View History

2018-08-20 08:53:13 +02:00
package i18n
import (
"fmt"
2018-08-26 07:46:18 +02:00
"io/ioutil"
2018-08-20 08:53:13 +02:00
"testing"
2018-08-23 14:22:03 +02:00
"github.com/sirupsen/logrus"
2018-08-20 08:53:13 +02:00
"github.com/stretchr/testify/assert"
)
2018-08-26 07:46:18 +02:00
func getDummyLog() *logrus.Entry {
log := logrus.New()
log.Out = ioutil.Discard
return log.WithField("test", "test")
}
2018-11-30 02:47:14 +02:00
// TestDetectLanguage is a function.
func TestDetectLanguage(t *testing.T) {
2018-08-20 08:53:13 +02:00
type scenario struct {
langDetector func() (string, error)
expected string
2018-08-20 08:53:13 +02:00
}
scenarios := []scenario{
{
func() (string, error) {
return "", fmt.Errorf("An error occurred")
2018-08-20 08:53:13 +02:00
},
"C",
2018-08-20 08:53:13 +02:00
},
{
func() (string, error) {
return "en", nil
2018-08-20 08:53:13 +02:00
},
"en",
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, detectLanguage(s.langDetector))
}
}