mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-10 10:26:46 +08:00
* test: remove implementation-only coverage Co-authored-by: multica-agent <[email protected]> * test: remove remaining implementation-only coverage Co-authored-by: multica-agent <[email protected]> * test: restore compatibility and fragment navigation coverage Co-authored-by: multica-agent <[email protected]> * test: preserve behavioral cleanup contracts Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Sol-Boy <[email protected]> Co-authored-by: multica-agent <[email protected]>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package telegram
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestClassifyCredentialVerificationError(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
err error
|
|
want error
|
|
}{
|
|
{
|
|
name: "Telegram rejects the token",
|
|
err: &apiError{Code: http.StatusUnauthorized, Description: "Unauthorized"},
|
|
want: ErrCredentialsRejected,
|
|
},
|
|
{
|
|
name: "Telegram rate limits verification",
|
|
err: &apiError{Code: http.StatusTooManyRequests, Description: "Too Many Requests"},
|
|
want: ErrCredentialsUnverifiable,
|
|
},
|
|
{
|
|
name: "transport cannot reach Telegram",
|
|
err: &requestError{method: "getMe", cause: errors.New("proxy connect failed")},
|
|
want: ErrCredentialsUnverifiable,
|
|
},
|
|
{
|
|
name: "malformed upstream response",
|
|
err: errors.New("decode response"),
|
|
want: ErrCredentialsUnverifiable,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if err := classifyCredentialVerificationError(tt.err); !errors.Is(err, tt.want) {
|
|
t.Fatalf("classifyCredentialVerificationError() = %v, want %v", err, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|