Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package signalbot
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestIntegrationPingGroupsSend runs against a real, linked service:
|
|
//
|
|
// SIGNALBOT_IT_URL=http://localhost:8080 SIGNALBOT_IT_GROUP=group.… go test -run Integration -v
|
|
func TestIntegrationPingGroupsSend(t *testing.T) {
|
|
url, group := os.Getenv("SIGNALBOT_IT_URL"), os.Getenv("SIGNALBOT_IT_GROUP")
|
|
if url == "" || group == "" {
|
|
t.Skip("set SIGNALBOT_IT_URL and SIGNALBOT_IT_GROUP to run")
|
|
}
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
c := mustNew(t, url, WithNumber(os.Getenv("SIGNALBOT_IT_NUMBER")))
|
|
if err := c.Ping(ctx); err != nil {
|
|
t.Fatalf("Ping: %v", err)
|
|
}
|
|
groups, err := c.Groups(ctx)
|
|
if err != nil {
|
|
t.Fatalf("Groups: %v", err)
|
|
}
|
|
found := false
|
|
for _, g := range groups {
|
|
found = found || g.ID == group
|
|
}
|
|
if !found {
|
|
t.Fatalf("group %s not in %+v", group, groups)
|
|
}
|
|
if err := c.Send(ctx, group, "signalbot integration test "+time.Now().Format(time.RFC3339)); err != nil {
|
|
t.Fatalf("Send: %v", err)
|
|
}
|
|
}
|