22 lines
634 B
Go
22 lines
634 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestHTTPBaseURL(t *testing.T) {
|
|
cases := []struct {
|
|
in, want string
|
|
}{
|
|
{"wss://studioe5.edudeploy.com/api/websocket", "https://studioe5.edudeploy.com"},
|
|
{"ws://localhost:3000/api/websocket", "http://localhost:3000"},
|
|
{"https://studioe5.edudeploy.com/api/websocket", "https://studioe5.edudeploy.com"},
|
|
{"https://studioe5.edudeploy.com", "https://studioe5.edudeploy.com"},
|
|
{"wss://example.com/api/websocket/", "https://example.com"},
|
|
}
|
|
for _, c := range cases {
|
|
got := httpBaseURL(c.in)
|
|
if got != c.want {
|
|
t.Errorf("httpBaseURL(%q) = %q, want %q", c.in, got, c.want)
|
|
}
|
|
}
|
|
}
|