mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
Merge pull request #67 from go-enry/test-fixture-upd
Test: update language name comparison
This commit is contained in:
commit
619127770d
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/go-enry/go-enry/v2/data"
|
||||
@ -252,14 +253,17 @@ func (s *EnryTestSuite) TestGetLanguagesByFilename() {
|
||||
{name: "TestGetLanguagesByFilename_4", filename: "Makefile.frag", expected: []string{"Makefile"}},
|
||||
{name: "TestGetLanguagesByFilename_5", filename: "makefile", expected: []string{"Makefile"}},
|
||||
{name: "TestGetLanguagesByFilename_6", filename: "Vagrantfile", expected: []string{"Ruby"}},
|
||||
{name: "TestGetLanguagesByFilename_7", filename: "_vimrc", expected: []string{"Vim script"}},
|
||||
{name: "TestGetLanguagesByFilename_7", filename: "_vimrc", expected: []string{"Vim Script"}},
|
||||
{name: "TestGetLanguagesByFilename_8", filename: "pom.xml", expected: []string{"Maven POM"}},
|
||||
{name: "TestGetLanguagesByFilename_9", filename: "", expected: nil},
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user