Tests: Add tests for /pkg
This commit is contained in:
parent
a01288a5ac
commit
ce9651df10
|
@ -41,6 +41,9 @@ func TestChroma_Hex(t *testing.T) {
|
|||
assert.Equal(t, "9B", perception.Chroma.Hex())
|
||||
})
|
||||
}
|
||||
func TestColor_Uint8(t *testing.T) {
|
||||
assert.Equal(t, uint8(7), Cyan.Uint8())
|
||||
}
|
||||
|
||||
func TestChroma_Value(t *testing.T) {
|
||||
lum := []Luminance{1, 16, 2, 4, 15, 16, 1, 0, 8}
|
||||
|
|
18
pkg/fs/birthtime_test.go
Normal file
18
pkg/fs/birthtime_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestBirthTime(t *testing.T) {
|
||||
t.Run("time now", func(t *testing.T) {
|
||||
result := BirthTime("/testdata/Test.jpg")
|
||||
assert.NotEmpty(t, result)
|
||||
})
|
||||
t.Run("mod time", func(t *testing.T) {
|
||||
result := BirthTime("./testdata/CATYELLOW.jpg")
|
||||
assert.NotEmpty(t, result)
|
||||
})
|
||||
}
|
|
@ -9,13 +9,20 @@ import (
|
|||
)
|
||||
|
||||
func TestCachePath(t *testing.T) {
|
||||
t.Run("error", func(t *testing.T) {
|
||||
t.Run("hash too short", func(t *testing.T) {
|
||||
result, err := CachePath("/foo/bar", "123", "baz", false)
|
||||
|
||||
assert.Equal(t, "", result)
|
||||
assert.EqualError(t, err, "cache: hash '123' is too short")
|
||||
})
|
||||
|
||||
t.Run("namespace empty", func(t *testing.T) {
|
||||
result, err := CachePath("/foo/bar", "123hjfju567695", "", false)
|
||||
|
||||
assert.Equal(t, "", result)
|
||||
assert.EqualError(t, err, "cache: namespace for hash '123hjfju567695' is empty")
|
||||
})
|
||||
|
||||
t.Run("1234567890abcdef", func(t *testing.T) {
|
||||
result, err := CachePath("/foo/bar", "1234567890abcdef", "baz", false)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
@ -14,3 +15,11 @@ func TestCaseInsensitive(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestIgnoreCase(t *testing.T) {
|
||||
assert.False(t, ignoreCase)
|
||||
IgnoreCase()
|
||||
assert.True(t, ignoreCase)
|
||||
ignoreCase = false
|
||||
assert.False(t, ignoreCase)
|
||||
}
|
||||
|
|
|
@ -85,4 +85,7 @@ func TestTitle(t *testing.T) {
|
|||
t.Run("NewYears", func(t *testing.T) {
|
||||
assert.Equal(t, "Boston New Year's", Title("boston new year's"))
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
assert.Empty(t, Title(""))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -37,6 +37,12 @@ func TestContainsSymbols(t *testing.T) {
|
|||
t.Run("réseau", func(t *testing.T) {
|
||||
assert.False(t, ContainsSymbols("réseau"))
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
assert.False(t, ContainsSymbols(""))
|
||||
})
|
||||
t.Run("...", func(t *testing.T) {
|
||||
assert.True(t, ContainsSymbols("😉"))
|
||||
})
|
||||
}
|
||||
|
||||
func TestContainsLetters(t *testing.T) {
|
||||
|
@ -61,6 +67,9 @@ func TestContainsLetters(t *testing.T) {
|
|||
t.Run("réseau", func(t *testing.T) {
|
||||
assert.True(t, ContainsLetters("réseau"))
|
||||
})
|
||||
t.Run("Empty", func(t *testing.T) {
|
||||
assert.Equal(t, false, ContainsLetters(""))
|
||||
})
|
||||
}
|
||||
|
||||
func TestContainsASCIILetters(t *testing.T) {
|
||||
|
|
|
@ -39,6 +39,9 @@ func TestIs(t *testing.T) {
|
|||
assert.True(t, Is(unicode.L, "réseau"))
|
||||
assert.True(t, Is(unicode.Letter, "réseau"))
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
assert.False(t, Is(unicode.Latin, ""))
|
||||
})
|
||||
}
|
||||
|
||||
func TestIsASCII(t *testing.T) {
|
||||
|
@ -84,4 +87,7 @@ func TestIsLatin(t *testing.T) {
|
|||
t.Run("réseau", func(t *testing.T) {
|
||||
assert.True(t, IsLatin("réseau"))
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
assert.False(t, IsLatin(""))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ func TestWords(t *testing.T) {
|
|||
result := Words("Île de la Réunion")
|
||||
assert.Equal(t, []string{"Île", "Réunion"}, result)
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
result := Words("")
|
||||
assert.Empty(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestReplaceSpaces(t *testing.T) {
|
||||
|
@ -73,6 +77,10 @@ func TestFilenameWords(t *testing.T) {
|
|||
result := FilenameWords("Île de la Réunion")
|
||||
assert.Equal(t, []string{"Île", "Réunion"}, result)
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
result := FilenameWords("")
|
||||
assert.Empty(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFilenameKeywords(t *testing.T) {
|
||||
|
@ -100,6 +108,10 @@ func TestFilenameKeywords(t *testing.T) {
|
|||
result := FilenameKeywords("Île de la Réunion")
|
||||
assert.Equal(t, []string{"île", "réunion"}, result)
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
result := FilenameKeywords("")
|
||||
assert.Empty(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestKeywords(t *testing.T) {
|
||||
|
@ -139,6 +151,10 @@ func TestKeywords(t *testing.T) {
|
|||
result := Keywords("Île de la Réunion")
|
||||
assert.Equal(t, []string{"île", "réunion"}, result)
|
||||
})
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
result := Keywords("")
|
||||
assert.Empty(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUniqueWords(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue