mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-27 06:42:04 -03:00
test: refactor and simplify TestLinguistSamples
test plan - go test -run '^Test_EnryOnLinguistCorpus$' github.com/go-enry/go-enry/v2
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-enry/go-enry/v2/data"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
@ -45,25 +44,23 @@ func (s *linguistCorpusSuite) TestLinguistSamples() {
|
||||
content, _ := ioutil.ReadFile(path)
|
||||
|
||||
total++
|
||||
obtained := GetLanguage(filename, content)
|
||||
if obtained == OtherLanguage {
|
||||
obtained = "Other"
|
||||
got := GetLanguage(filename, content)
|
||||
if got == OtherLanguage {
|
||||
got = "Other"
|
||||
other++
|
||||
}
|
||||
|
||||
var status string
|
||||
if expected == obtained {
|
||||
status = "ok"
|
||||
if expected == got {
|
||||
ok++
|
||||
} else {
|
||||
status = "failed"
|
||||
failed++
|
||||
}
|
||||
|
||||
errMsg := fmt.Sprintf("file: %q\texpected: %q\tgot: %q\n", path, expected, got)
|
||||
if _, ok := cornerCases[filename]; ok {
|
||||
s.T().Logf("\t\t[considered corner case] %s\texpected: %s\tobtained: %s\tstatus: %s\n", filename, expected, obtained, status)
|
||||
s.T().Logf(fmt.Sprintf("\t\t[corner case] %s", errMsg))
|
||||
} else {
|
||||
assert.Equal(s.T(), expected, obtained, fmt.Sprintf("%s\texpected: %s\tobtained: %s\tstatus: %s\n", filename, expected, obtained, status))
|
||||
s.Equal(expected, got, errMsg)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
Reference in New Issue
Block a user