-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaccess_url_test.go
More file actions
76 lines (65 loc) · 1.95 KB
/
access_url_test.go
File metadata and controls
76 lines (65 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package v1
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestWorkspaceURLForSpritzUsesIngressPath(t *testing.T) {
spritz := &Spritz{
ObjectMeta: metav1ObjectMeta("openclaw-tide-wind", "spritz-test"),
Spec: SpritzSpec{
Ingress: &SpritzIngress{
Host: "console.example.com",
Path: "/w/openclaw-tide-wind",
},
},
}
if got := WorkspaceURLForSpritz(spritz); got != "https://console.example.com/w/openclaw-tide-wind/" {
t.Fatalf("expected workspace url, got %q", got)
}
}
func TestChatURLForSpritzUsesRootHashRoute(t *testing.T) {
spritz := &Spritz{
ObjectMeta: metav1ObjectMeta("openclaw-tide-wind", "spritz-test"),
Spec: SpritzSpec{
Ingress: &SpritzIngress{
Host: "console.example.com",
Path: "/w/openclaw-tide-wind",
},
},
}
if got := ChatURLForSpritz(spritz); got != "https://console.example.com/#chat/openclaw-tide-wind" {
t.Fatalf("expected chat url, got %q", got)
}
}
func TestAccessURLForSpritzPromotesChatURL(t *testing.T) {
spritz := &Spritz{
ObjectMeta: metav1ObjectMeta("openclaw-tide-wind", "spritz-test"),
Spec: SpritzSpec{
Ingress: &SpritzIngress{
Host: "console.example.com",
Path: "/w/openclaw-tide-wind",
},
},
}
if got := AccessURLForSpritz(spritz); got != "https://console.example.com/#chat/openclaw-tide-wind" {
t.Fatalf("expected access url to prefer chat url, got %q", got)
}
}
func TestAccessURLForSpritzFallsBackToWorkspaceURL(t *testing.T) {
spritz := &Spritz{
ObjectMeta: metav1ObjectMeta("openclaw-tide-wind", "spritz-test"),
Spec: SpritzSpec{
Ports: []SpritzPort{{ContainerPort: 8080}},
},
}
want := "http://openclaw-tide-wind.spritz-test.svc.cluster.local:8080/#chat/openclaw-tide-wind"
if got := AccessURLForSpritz(spritz); got != want {
t.Fatalf("expected access url %q, got %q", want, got)
}
}
func metav1ObjectMeta(name, namespace string) metav1.ObjectMeta {
return metav1.ObjectMeta{
Name: name,
Namespace: namespace,
}
}