mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
599bfb5ca8
Fix WeCom adapter typos and strict Go lint findings (gosec/bodyclose/errcheck/revive) while keeping runtime behavior unchanged.
30 lines
786 B
Go
30 lines
786 B
Go
package wecom
|
|
|
|
import "testing"
|
|
|
|
func TestBuildFrameAndDecodeBody(t *testing.T) {
|
|
type body struct {
|
|
BotID string `json:"bot_id"`
|
|
}
|
|
frame, err := BuildFrame(WSCmdSubscribe, "req-1", body{BotID: "bot123"})
|
|
if err != nil {
|
|
t.Fatalf("BuildFrame error = %v", err)
|
|
}
|
|
var decoded body
|
|
if err := frame.DecodeBody(&decoded); err != nil {
|
|
t.Fatalf("DecodeBody error = %v", err)
|
|
}
|
|
if decoded.BotID != "bot123" {
|
|
t.Fatalf("unexpected decoded body: %+v", decoded)
|
|
}
|
|
}
|
|
|
|
func TestAuthCredentialsValidate(t *testing.T) {
|
|
if err := (AuthCredentials{}).Validate(); err == nil {
|
|
t.Fatal("expected validation error for empty credentials")
|
|
}
|
|
if err := (AuthCredentials{BotID: "id", Credential: "sec"}).Validate(); err != nil {
|
|
t.Fatalf("unexpected validation error: %v", err)
|
|
}
|
|
}
|