mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
Added support for third party packages on httptest package with tests & example. (#1992)
* Added support for third party packages on httptest package with tests. * Update httptest.go Co-authored-by: Gerasimos (Makis) Maropoulos <kataras2006@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
bdceab9342
commit
c1fa064d98
@@ -4,7 +4,6 @@ import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/kataras/iris/v12/context"
|
||||
@@ -106,7 +105,7 @@ func DefaultConfiguration() *Configuration {
|
||||
// httptest.New(t, app, httptest.URL(...), httptest.Debug(true), httptest.LogLevel("debug"), httptest.Strict(true))
|
||||
//
|
||||
// Example at: https://github.com/kataras/iris/tree/master/_examples/testing/httptest.
|
||||
func New(t *testing.T, app *iris.Application, setters ...OptionSetter) *httpexpect.Expect {
|
||||
func New(t IrisTesty, app *iris.Application, setters ...OptionSetter) *httpexpect.Expect {
|
||||
conf := DefaultConfiguration()
|
||||
for _, setter := range setters {
|
||||
setter.Set(conf)
|
||||
@@ -150,7 +149,7 @@ func New(t *testing.T, app *iris.Application, setters ...OptionSetter) *httpexpe
|
||||
|
||||
// NewInsecure same as New but receives a single host instead of the whole framework.
|
||||
// Useful for testing running TLS servers.
|
||||
func NewInsecure(t *testing.T, setters ...OptionSetter) *httpexpect.Expect {
|
||||
func NewInsecure(t IrisTesty, setters ...OptionSetter) *httpexpect.Expect {
|
||||
conf := DefaultConfiguration()
|
||||
for _, setter := range setters {
|
||||
setter.Set(conf)
|
||||
@@ -203,3 +202,24 @@ func Do(w http.ResponseWriter, r *http.Request, handler iris.Handler, irisConfig
|
||||
handler(ctx)
|
||||
app.ContextPool.Release(ctx)
|
||||
}
|
||||
|
||||
type IrisTesty interface {
|
||||
Cleanup(func())
|
||||
Error(args ...any)
|
||||
Errorf(format string, args ...any)
|
||||
Fail()
|
||||
FailNow()
|
||||
Failed() bool
|
||||
Fatal(args ...any)
|
||||
Fatalf(format string, args ...any)
|
||||
Helper()
|
||||
Log(args ...any)
|
||||
Logf(format string, args ...any)
|
||||
Name() string
|
||||
Setenv(key, value string)
|
||||
Skip(args ...any)
|
||||
SkipNow()
|
||||
Skipf(format string, args ...any)
|
||||
Skipped() bool
|
||||
TempDir() string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user