diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-09-21 18:53:29 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-09-21 22:23:23 -0700 |
commit | beb7a0cfcb6a5a76d680707a4c458eee51d87c07 (patch) | |
tree | f6e23ffbffcdd58f8438e2d2711acb4fa86bb83b /locale/parser_test.go | |
parent | f244df62936eea307a5fc3f27fb9968527d402ac (diff) |
Use unique translation IDs instead of English text as key
Diffstat (limited to 'locale/parser_test.go')
-rw-r--r-- | locale/parser_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/locale/parser_test.go b/locale/parser_test.go new file mode 100644 index 0000000..619d8db --- /dev/null +++ b/locale/parser_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 := parseCatalogMessages(`{`) + if err == nil { + t.Fatal(`An error should be returned when parsing invalid data`) + } +} + +func TestParser(t *testing.T) { + translations, err := parseCatalogMessages(`{"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`) + } +} |