TestMain ensures i18n is initialized before any test runs so T() returns real translations instead of the raw key strings.
(m *testing.M)
| 15 | // TestMain ensures i18n is initialized before any test runs so T() returns |
| 16 | // real translations instead of the raw key strings. |
| 17 | func TestMain(m *testing.M) { |
| 18 | // Force English for stable, locale-independent test assertions. |
| 19 | _ = os.Setenv("CHATCLI_LANG", "en") |
| 20 | i18n.Init() |
| 21 | os.Exit(m.Run()) |
| 22 | } |
| 23 | |
| 24 | // captureStdout swaps os.Stdout for a pipe, runs fn, and returns the |
| 25 | // captured output. Used to assert that each /config section renders without |