aboutsummaryrefslogtreecommitdiffhomepage
path: root/locale/catalog_test.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-09-22 15:04:55 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-09-22 15:04:55 -0700
commitb1e8f534eff7569dc2e8dab4dee851d1b709f71b (patch)
treeec9d5cbebc78704727c9ce959f442b3df5cc7d76 /locale/catalog_test.go
parentaae9b4eb835c72c0b7ecd8fa6565eacce3963d00 (diff)
Simplify locale package usage (refactoring)
Diffstat (limited to 'locale/catalog_test.go')
-rw-r--r--locale/catalog_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/locale/catalog_test.go b/locale/catalog_test.go
new file mode 100644
index 0000000..0be9995
--- /dev/null
+++ b/locale/catalog_test.go
@@ -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`)
+ }
+}