mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 22:23:07 -03:00
refactoring: remove un-used code, add go doc, fix ci (#199)
Refactoring, consisting of - remove unused method `isAuxiliaryLanguage` and `FileCountList` in order to reduce public API surfaces (go/java) - add GoDoc to public APIs - ci: java profile use latest go src It also now mimics https://docs.travis-ci.com/user/languages/go/#go-import-path for non-go build image, as code relies on internal imports. TEST PLAN: - make test
This commit is contained in:
@ -3,38 +3,11 @@ package enry
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsAuxiliaryLanguage(t *testing.T) {
|
||||
type testType struct {
|
||||
name string
|
||||
lang string
|
||||
expected bool
|
||||
}
|
||||
|
||||
tests := []testType{
|
||||
{name: "TestIsAuxiliaryLanguage_Invalid", lang: "invalid", expected: false},
|
||||
}
|
||||
for k := range auxiliaryLanguages {
|
||||
t := testType{
|
||||
name: fmt.Sprintf("TestIsAuxiliaryLanguage_%s", k),
|
||||
lang: k,
|
||||
expected: true,
|
||||
}
|
||||
tests = append(tests, t)
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsAuxiliaryLanguage(test.lang)
|
||||
assert.Equal(t, is, test.expected,
|
||||
fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsVendor(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -106,7 +79,7 @@ func TestGetMimeType(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
is := GetMimeType(test.path, test.lang)
|
||||
is := GetMIMEType(test.path, test.lang)
|
||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
@ -160,43 +133,3 @@ func TestIsDotFile(t *testing.T) {
|
||||
assert.Equal(t, test.expected, is, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileCountListSort(t *testing.T) {
|
||||
sampleData := FileCountList{{"a", 8}, {"b", 65}, {"c", 20}, {"d", 90}}
|
||||
const ascending = "ASC"
|
||||
const descending = "DESC"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
data FileCountList
|
||||
order string
|
||||
expectedData FileCountList
|
||||
}{
|
||||
{
|
||||
name: "ascending order",
|
||||
data: sampleData,
|
||||
order: ascending,
|
||||
expectedData: FileCountList{{"a", 8}, {"c", 20}, {"b", 65}, {"d", 90}},
|
||||
},
|
||||
{
|
||||
name: "descending order",
|
||||
data: sampleData,
|
||||
order: descending,
|
||||
expectedData: FileCountList{{"d", 90}, {"b", 65}, {"c", 20}, {"a", 8}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if test.order == descending {
|
||||
sort.Sort(sort.Reverse(test.data))
|
||||
} else {
|
||||
sort.Sort(test.data)
|
||||
}
|
||||
|
||||
for i := 0; i < len(test.data); i++ {
|
||||
assert.Equal(t, test.data[i], test.expectedData[i], fmt.Sprintf("%v: FileCount at position %d = %v, expected: %v", test.name, i, test.data[i], test.expectedData[i]))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user