Improve test coverage to ~100%
This commit is contained in:
@@ -6,6 +6,29 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGettersSetters(t *testing.T) {
|
||||
SetDomain("test")
|
||||
dom := GetDomain()
|
||||
|
||||
if dom != "test" {
|
||||
t.Errorf("Expected GetDomain to return 'test', but got '%s'", dom)
|
||||
}
|
||||
|
||||
SetLibrary("/tmp/test")
|
||||
lib := GetLibrary()
|
||||
|
||||
if lib != "/tmp/test" {
|
||||
t.Errorf("Expected GetLibrary to return '/tmp/test', but got '%s'", lib)
|
||||
}
|
||||
|
||||
SetLanguage("es")
|
||||
lang := GetLanguage()
|
||||
|
||||
if lang != "es" {
|
||||
t.Errorf("Expected GetLanguage to return 'es', but got '%s'", lang)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageFunctions(t *testing.T) {
|
||||
// Set PO content
|
||||
str := `# Some comment
|
||||
@@ -23,7 +46,10 @@ msgstr[1] "This one is the plural: %s"
|
||||
msgstr[2] "And this is the second plural form: %s"
|
||||
|
||||
`
|
||||
|
||||
|
||||
// Set default configuration
|
||||
Configure("/tmp", "en_US", "default")
|
||||
|
||||
// Create Locales directory on default location
|
||||
dirname := path.Clean(library + string(os.PathSeparator) + "en_US")
|
||||
err := os.MkdirAll(dirname, os.ModePerm)
|
||||
@@ -109,14 +135,14 @@ msgstr[2] "And this is the second plural form: %s"
|
||||
|
||||
// Test translations
|
||||
go func(done chan bool) {
|
||||
println(Get("My text"))
|
||||
Get("My text")
|
||||
done <- true
|
||||
}(c1)
|
||||
|
||||
go func(done chan bool) {
|
||||
println(Get("My text"))
|
||||
Get("My text")
|
||||
done <- true
|
||||
}(c2)
|
||||
|
||||
println(Get("My text"))
|
||||
Get("My text")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user