(new): expand runtime APIs
Golang lint / lint (push) Successful in 58s
Golang lint / lint (pull_request) Successful in 13m10s

(fix): harden concurrent lifecycle
(tests): add regression coverage
(doc): update v1.2 guidance
This commit is contained in:
2026-08-20 11:08:45 +03:00
parent 29b208eeec
commit 24040fe164
37 changed files with 1129 additions and 157 deletions
+29
View File
@@ -1,6 +1,9 @@
package tgapi
import (
"errors"
"fmt"
"net/url"
"strings"
"testing"
)
@@ -37,3 +40,29 @@ func TestResponseLogSummaryNeverContainsBody(t *testing.T) {
t.Fatalf("response summary does not explain omission: %s", got)
}
}
func TestRedactHTTPErrorRemovesTokenAndPreservesCause(t *testing.T) {
const token = "123456:secret-token"
cause := errors.New("transport failed")
original := &url.Error{
Op: "Post",
URL: "https://api.telegram.org/bot" + token + "/sendMessage",
Err: fmt.Errorf("request for %s failed: %w", token, cause),
}
got := redactHTTPError(original, token)
if strings.Contains(got.Error(), token) {
t.Fatalf("redacted HTTP error contains bot token: %v", got)
}
if !errors.Is(got, cause) {
t.Fatalf("redacted HTTP error lost its cause: %v", got)
}
var gotURLError *url.Error
if !errors.As(got, &gotURLError) {
t.Fatalf("redacted HTTP error lost url.Error type: %T", got)
}
if strings.Contains(gotURLError.Error(), token) {
t.Fatalf("redacted url.Error contains bot token: %v", gotURLError)
}
}