diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-02-12 19:18:05 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-02-19 14:15:07 +0100 |
| commit | 74e36f0ead717105f26087c2cab08b41ba5a7ce8 (patch) | |
| tree | 1eb2b7516bea705c9b5a50ce0965e170414ed880 /internal/test | |
| parent | 682d70091af2044ff6d8b350da9dff13163232e2 (diff) | |
All: Document everything to pass revive lint
Diffstat (limited to 'internal/test')
| -rw-r--r-- | internal/test/error.go | 1 | ||||
| -rw-r--r-- | internal/test/handler.go | 2 | ||||
| -rw-r--r-- | internal/test/server.go | 3 |
3 files changed, 5 insertions, 1 deletions
diff --git a/internal/test/error.go b/internal/test/error.go index 98fa09b..b2ddd12 100644 --- a/internal/test/error.go +++ b/internal/test/error.go @@ -2,6 +2,7 @@ package test import "testing" +// AssertError asserts an error by checking if the `Error()` strings are equal func AssertError(t *testing.T, err error, wantErr string) { gv := "" if err != nil { diff --git a/internal/test/handler.go b/internal/test/handler.go index 3991c6a..bb5f7a0 100644 --- a/internal/test/handler.go +++ b/internal/test/handler.go @@ -11,12 +11,14 @@ type HandlerSet struct { handler http.Handler } +// SetHandler sets the handler to `handler` func (hs *HandlerSet) SetHandler(handler http.Handler) { hs.mu.Lock() hs.handler = handler hs.mu.Unlock() } +// ServeHTTP serves HTTP using the handler func (hs *HandlerSet) ServeHTTP(w http.ResponseWriter, r *http.Request) { hs.mu.Lock() handler := hs.handler diff --git a/internal/test/server.go b/internal/test/server.go index 6d6a0c2..6c1b418 100644 --- a/internal/test/server.go +++ b/internal/test/server.go @@ -10,13 +10,14 @@ import ( httpw "github.com/eduvpn/eduvpn-common/internal/http" ) +// Server wraps a HTTP test server type Server struct { *httptest.Server } +// NewServer creates a new test server func NewServer(handler http.Handler) *Server { s := httptest.NewTLSServer(handler) - return &Server{s} } |
