1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-08 06:25:37 -05:00
Files
DankMaterialShell/backend/internal/server/bluez/handlers_test.go
2025-11-12 17:18:45 -05:00

42 lines
763 B
Go

package bluez
import (
"context"
"testing"
"time"
)
func TestBrokerIntegration(t *testing.T) {
broker := NewSubscriptionBroker(nil)
ctx := context.Background()
req := PromptRequest{
DevicePath: "/org/bluez/test",
DeviceName: "TestDevice",
RequestType: "pin",
Fields: []string{"pin"},
}
token, err := broker.Ask(ctx, req)
if err != nil {
t.Fatalf("Ask failed: %v", err)
}
go func() {
time.Sleep(50 * time.Millisecond)
broker.Resolve(token, PromptReply{
Secrets: map[string]string{"pin": "1234"},
Accept: true,
})
}()
reply, err := broker.Wait(ctx, token)
if err != nil {
t.Fatalf("Wait failed: %v", err)
}
if reply.Secrets["pin"] != "1234" {
t.Errorf("expected pin=1234, got %s", reply.Secrets["pin"])
}
}