Skip to content

Commit

Permalink
Remove config test involving HTTP server options
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlAmko committed Sep 14, 2023
1 parent f390132 commit d0e95b6
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"net/http"
"reflect"
"testing"

Expand All @@ -20,14 +19,6 @@ func assertSlice[T any](opts []any) []T {
return out
}

func handlerPtr(h http.Handler) *http.Handler {
return &h
}

func serverPtr(srv *http.Server) **http.Server {
return &srv
}

func labelPtr(labels map[string]*string) *map[string]*string {
return &labels
}
Expand Down Expand Up @@ -61,8 +52,6 @@ type testCase[T tunnelConfigPrivate, O any] struct {
expectProto *string
expectExtra *matchBindExtra
expectLabels *map[string]*string
expectHTTPServer **http.Server // TODO: deprecate
expectHTTPHandler *http.Handler // TODO: deprecate
expectOpts func(t *testing.T, opts *O)
expectNilOpts bool
}
Expand Down Expand Up @@ -101,37 +90,6 @@ func (tc testCase[T, O]) Run(t *testing.T) {
require.Truef(t, ok, "Opts has the type %v", reflect.TypeOf((*O)(nil)))
tc.expectOpts(t, opts)
}

if tc.expectHTTPServer != nil {
withHTTPServer, ok := tc.opts.(interface {
HTTPServer() *http.Server
})
if *tc.expectHTTPServer != nil {
require.True(t, ok, "opts should have the HTTPServer method")
actual := withHTTPServer.HTTPServer()
require.Equal(t, *tc.expectHTTPServer, actual)
} else if ok {
require.Nil(t, withHTTPServer.HTTPServer())
}
}

if tc.expectHTTPHandler != nil {
withHTTPServer, ok := tc.opts.(interface {
HTTPServer() *http.Server
})
if *tc.expectHTTPHandler != nil {
require.True(t, ok, "opts should have the HTTPServer method")
actualServer := withHTTPServer.HTTPServer()
require.NotNil(t, actualServer)
actual := actualServer.Handler
require.Equal(t, *tc.expectHTTPHandler, actual)
} else if ok {
actualServer := withHTTPServer.HTTPServer()
if actualServer != nil {
require.Nil(t, actualServer.Handler)
}
}
}
})
}

Expand Down

0 comments on commit d0e95b6

Please sign in to comment.