mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Simplify locale package usage (refactoring)
This commit is contained in:
parent
aae9b4eb83
commit
b1e8f534ef
26 changed files with 443 additions and 299 deletions
34
locale/catalog_test.go
Normal file
34
locale/catalog_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package locale // import "miniflux.app/locale"
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParserWithInvalidData(t *testing.T) {
|
||||
_, err := parseTranslationDict(`{`)
|
||||
if err == nil {
|
||||
t.Fatal(`An error should be returned when parsing invalid data`)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParser(t *testing.T) {
|
||||
translations, err := parseTranslationDict(`{"k": "v"}`)
|
||||
if err != nil {
|
||||
t.Fatalf(`Unexpected parsing error: %v`, err)
|
||||
}
|
||||
|
||||
if translations == nil {
|
||||
t.Fatal(`Translations should not be nil`)
|
||||
}
|
||||
|
||||
value, found := translations["k"]
|
||||
if !found {
|
||||
t.Fatal(`The translation should contains the defined key`)
|
||||
}
|
||||
|
||||
if value.(string) != "v" {
|
||||
t.Fatal(`The translation key should contains the defined value`)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue