package wsutil import "testing" func TestAppendQuery_PreservesExisting(t *testing.T) { t.Parallel() got := AppendQuery("wss://gw.example.com/gateway?compress=0&token=abc", map[string]string{ "resume": "1", "sn": "5", "session_id": "sess-123", }) want := "wss://gw.example.com/gateway?compress=0&token=abc&resume=1&session_id=sess-123&sn=5" if got != want { t.Errorf("AppendQuery = %q, want %q", got, want) } } func TestAppendQuery_NoExisting(t *testing.T) { t.Parallel() got := AppendQuery("wss://gw.example.com/gateway", map[string]string{"a": "1", "b": "2"}) want := "wss://gw.example.com/gateway?a=1&b=2" if got != want { t.Errorf("AppendQuery = %q, want %q", got, want) } } func TestAppendQuery_OmitsEmptyValue(t *testing.T) { t.Parallel() got := AppendQuery("wss://gw.example.com/gateway?x=1", map[string]string{"sn": "", "resume": "1"}) want := "wss://gw.example.com/gateway?x=1&resume=1" if got != want { t.Errorf("AppendQuery = %q, want %q", got, want) } } func TestAppendQuery_EmptyParams(t *testing.T) { t.Parallel() got := AppendQuery("wss://gw.example.com/gateway?x=1", nil) if got != "wss://gw.example.com/gateway?x=1" { t.Errorf("AppendQuery nil = %q, want unchanged", got) } }