Help us shape the future of Go! Take the 2026 Go Developer Survey

problemtest

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package problemtest checks that a client's message catalog covers an application's problem types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckArgs

func CheckArgs(msg string, params []string) error

CheckArgs returns an error if the ICU message msg does not parse or uses an argument not in params.

func CheckCatalog

func CheckCatalog(tb testing.TB, path string, registries ...*problem.Registry)

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

func CheckGoCatalog(tb testing.TB, c *problem.Catalog, registries ...*problem.Registry)

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

func CheckGoCatalogComplete(tb testing.TB, c *problem.Catalog, registries ...*problem.Registry)

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

func CheckMessages(tb testing.TB, messages map[string]string, registries ...*problem.Registry)

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

func MessageArgs(msg string) ([]string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL