carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package tunnelclient
2
3import (
4 "net/http"
5 "net/http/httptest"
6 "testing"
7)
8
9func TestMarkIsOnlyOnMarkedHandlers(t *testing.T) {
10 var saw bool
11 h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { saw = FromTunnel(r.Context()) })
12 h.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", "/", nil))
13 if saw {
14 t.Fatal("an unmarked handler saw the mark")
15 }
16 Mark(h).ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", "/", nil))
17 if !saw {
18 t.Fatal("Mark did not mark")
19 }
20}
21