From 0c3a5927bb15d1647e3bf929b3380378d8b0da55 Mon Sep 17 00:00:00 2001 From: Alex Bezzubov Date: Sun, 14 Nov 2021 18:25:26 +0100 Subject: [PATCH] test: case-insensitive language name comparison --- common_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common_test.go b/common_test.go index fb552d8..d99b4de 100644 --- a/common_test.go +++ b/common_test.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" "testing" "github.com/go-enry/go-enry/v2/data" @@ -259,7 +260,10 @@ func (s *EnryTestSuite) TestGetLanguagesByFilename() { for _, test := range tests { languages := GetLanguagesByFilename(test.filename, test.content, test.candidates) - assert.Equal(s.T(), test.expected, languages, fmt.Sprintf("%v: languages = %v, expected: %v", test.name, languages, test.expected)) + assert.Equal(s.T(), len(test.expected), len(languages), fmt.Sprintf("%v: number of languages = %v, expected: %v", test.name, len(languages), len(test.expected))) + for i := range languages { // case-insensitive name comparison + assert.True(s.T(), strings.EqualFold(test.expected[i], languages[i]), fmt.Sprintf("%v: languages = %v, expected: %v", test.name, languages, test.expected)) + } } }