(new): rich message support
(fix): runtime reliability (tests): regression coverage (doc): v1.1 release notes
This commit is contained in:
@@ -82,6 +82,25 @@ func TestLoadBotOptsFileExpandsEnvPlaceholders(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBotOptsFileEscapesEnvironmentValuesForJSON(t *testing.T) {
|
||||
want := "quote: \"; slash: \\; newline:\n; tab:\t; control:\x01"
|
||||
t.Setenv("TG_TOKEN", want)
|
||||
|
||||
dir := t.TempDir()
|
||||
filename := filepath.Join(dir, "config.json")
|
||||
if err := os.WriteFile(filename, []byte(`{"token":"{{TG_TOKEN}}"}`), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile returned error: %v", err)
|
||||
}
|
||||
|
||||
got, err := LoadBotOptsFile(BotOptsFileJSONCodec{}, filename)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadBotOptsFile returned error: %v", err)
|
||||
}
|
||||
if got.Token != want {
|
||||
t.Fatalf("unexpected token: got %q want %q", got.Token, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBotOptsFileReturnsDecodeError(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
filename := filepath.Join(dir, "config.json")
|
||||
|
||||
Reference in New Issue
Block a user