package toolkit import ( "os" "testing" ) func TestExpand(t *testing.T) { t.Setenv("TOOLKIT_TEST_VAR", "value") got := string(Expand([]byte(`{"x":"${TOOLKIT_TEST_VAR}","y":"static"}`))) want := `{"x":"value","y":"static"}` if got != want { t.Errorf("Expand = %q, want %q", got, want) } // Неизвестная переменная → пустая строка (fail-closed далее по валидации). os.Unsetenv("TOOLKIT_TEST_MISSING") got = string(Expand([]byte(`"${TOOLKIT_TEST_MISSING}"`))) if got != `""` { t.Errorf("Expand(missing) = %q, want empty", got) } } func TestHealth(t *testing.T) { orig := os.Args defer func() { os.Args = orig }() os.Args = []string{"prog", "--health"} if !Health() { t.Error("Health() = false with --health") } os.Args = []string{"prog", "-config", "x"} if Health() { t.Error("Health() = true without --health") } }