MCPcopy Index your code
hub / github.com/coder/coder / TestParseSubdomainAppURL

Function TestParseSubdomainAppURL

coderd/workspaceapps/appurl/appurl_test.go:127–294  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestParseSubdomainAppURL(t *testing.T) {
128 t.Parallel()
129 testCases := []struct {
130 Name string
131 Subdomain string
132 Expected appurl.ApplicationURL
133 ExpectedError string
134 }{
135 {
136 Name: "Invalid_Empty",
137 Subdomain: "test",
138 Expected: appurl.ApplicationURL{},
139 ExpectedError: "invalid application url format",
140 },
141 {
142 Name: "Invalid_Workspace.Agent--App",
143 Subdomain: "workspace.agent--app",
144 Expected: appurl.ApplicationURL{},
145 ExpectedError: "invalid application url format",
146 },
147 {
148 Name: "Invalid_Workspace--App",
149 Subdomain: "workspace--app",
150 Expected: appurl.ApplicationURL{},
151 ExpectedError: "invalid application url format",
152 },
153 {
154 Name: "Valid_App--Workspace--User",
155 Subdomain: "app--workspace--user",
156 Expected: appurl.ApplicationURL{
157 AppSlugOrPort: "app",
158 AgentName: "", // Agent name is optional when app slug is present
159 WorkspaceName: "workspace",
160 Username: "user",
161 },
162 },
163 {
164 Name: "Invalid_TooManyComponents",
165 Subdomain: "1--2--3--4--5",
166 Expected: appurl.ApplicationURL{},
167 ExpectedError: "invalid application url format",
168 },
169 {
170 Name: "Invalid_Port--Workspace--User",
171 Subdomain: "8080--workspace--user",
172 Expected: appurl.ApplicationURL{},
173 ExpectedError: "agent name is required for port-based URLs",
174 },
175 // Correct
176 {
177 Name: "AppName--Agent--Workspace--User",
178 Subdomain: "app--agent--workspace--user",
179 Expected: appurl.ApplicationURL{
180 AppSlugOrPort: "app",
181 AgentName: "",
182 WorkspaceName: "workspace",
183 Username: "user",
184 },

Callers

nothing calls this directly

Calls 3

ParseSubdomainAppURLFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected