MCPcopy
hub / github.com/coder/websocket / checkWSTestIndex

Function checkWSTestIndex

autobahn_test.go:237–270  ·  view source on GitHub ↗
(t *testing.T, path string)

Source from the content-addressed store, hash-verified

235}
236
237func checkWSTestIndex(t *testing.T, path string) {
238 wstestOut, err := os.ReadFile(path)
239 assert.Success(t, err)
240
241 var indexJSON map[string]map[string]struct {
242 Behavior string `json:"behavior"`
243 BehaviorClose string `json:"behaviorClose"`
244 }
245 err = json.Unmarshal(wstestOut, &indexJSON)
246 assert.Success(t, err)
247
248 for _, tests := range indexJSON {
249 for test, result := range tests {
250 t.Run(test, func(t *testing.T) {
251 switch result.BehaviorClose {
252 case "OK", "INFORMATIONAL":
253 default:
254 t.Errorf("bad close behaviour")
255 }
256
257 switch result.Behavior {
258 case "OK", "NON-STRICT", "INFORMATIONAL":
259 default:
260 t.Errorf("failed")
261 }
262 })
263 }
264 }
265
266 if t.Failed() {
267 htmlPath := strings.Replace(path, ".json", ".html", 1)
268 t.Errorf("detected autobahn violation, see %q", htmlPath)
269 }
270}
271
272func unusedListenAddr() (_ string, err error) {
273 defer errd.Wrap(&err, "failed to get unused listen address")

Callers 1

TestAutobahnFunction · 0.85

Calls 1

SuccessFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…