Documentation
¶
Overview ¶
Package problemtest checks that a client's message catalog covers an application's problem types.
Index ¶
- func CheckArgs(msg string, params []string) error
- func CheckCatalog(tb testing.TB, path string, registries ...*problem.Registry)
- func CheckGoCatalog(tb testing.TB, c *problem.Catalog, registries ...*problem.Registry)
- func CheckGoCatalogComplete(tb testing.TB, c *problem.Catalog, registries ...*problem.Registry)
- func CheckMessages(tb testing.TB, messages map[string]string, registries ...*problem.Registry)
- func MessageArgs(msg string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckArgs ¶
CheckArgs returns an error if the ICU message msg does not parse or uses an argument not in params.
func CheckCatalog ¶
CheckCatalog fails tb unless the JSON catalog at path has a message for every type in registries, using only the type's Params as ICU arguments. It reads apiErrors as useCodeMessage in @parallelworks/problem/react does: a type's message is at apiErrors.<name>.<code>, under its registry's name, when the catalog has one there, and otherwise at apiErrors.<code>. So an application's own codes can stay at the top level while another registry's go under its name. Messages nest one level, as a type URI names one application; a deeper object, or a value that is no message, fails to parse. The shared codes' messages ship with @parallelworks/problem, so the catalog needs only the applications' own.
func CheckGoCatalog ¶ added in v0.11.0
CheckGoCatalog fails tb unless c, a catalog a server localizes problems with, has an English message for every type in registries, and every language's message for a type uses only the type's Params. A language missing a type's message falls back to English; CheckGoCatalogComplete fails on that too.
func CheckGoCatalogComplete ¶ added in v0.15.0
CheckGoCatalogComplete is CheckGoCatalog that also fails unless every language c has, not only English, has a message for every type in registries, so no reader in a language the server offers is shown English.
func CheckMessages ¶ added in v0.6.0
CheckMessages is CheckCatalog for an apiErrors map the caller has already loaded, such as a catalog split into one file per namespace. Its keys are those CheckCatalog reads, with a message under an application's name at <name>.<code>, so a split catalog can pass an application's messages either flattened under its name or at the top level.
func MessageArgs ¶
MessageArgs returns the names of the arguments an ICU message format string uses, including those inside plural and select branches.
Types ¶
This section is empty.