@@ -2,6 +2,7 @@ package tgapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -109,6 +110,25 @@ func TestGetFileByLinkReturnsHTTPStatusError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFileByLinkLimitRejectsOversizedResponse(t *testing.T) {
|
||||
api := NewAPI(
|
||||
NewAPIOpts("token").
|
||||
SetAPIURL("https://example.test").
|
||||
SetHTTPClient(&http.Client{Transport: roundTripFunc(func(_ *http.Request) (*http.Response, error) {
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: io.NopCloser(strings.NewReader("12345")),
|
||||
}, nil
|
||||
})}),
|
||||
)
|
||||
defer func() { _ = api.Close() }()
|
||||
|
||||
_, err := api.GetFileByLinkLimit("files/report.txt", 4)
|
||||
if !errors.Is(err, ErrFileTooLarge) {
|
||||
t.Fatalf("expected ErrFileTooLarge, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetUpdatesOmitsAllowedUpdatesWhenEmpty(t *testing.T) {
|
||||
var gotBody map[string]any
|
||||
|
||||
|
||||
Reference in New Issue
Block a user