summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-05-27 00:13:54 +0300
committerValery Piashchynski <[email protected]>2021-05-27 00:13:54 +0300
commitcfaf3e5f8465d188546ef83600ad13c7dbde778c (patch)
tree982e5498e2a92561a83ef9dc8b9669b0bafebc50
parentdc3c5455e5c9b32737a0620c8bdb8bda0226dba7 (diff)
- Fix naming after bulk refactoring handler2 -> handler
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r--tests/plugins/http/handler_test.go64
-rw-r--r--tests/plugins/http/parse_test.go6
-rw-r--r--tests/plugins/http/response_test.go18
-rw-r--r--tests/plugins/http/uploads_test.go10
4 files changed, 49 insertions, 49 deletions
diff --git a/tests/plugins/http/handler_test.go b/tests/plugins/http/handler_test.go
index 4c7ab215..1fa29783 100644
--- a/tests/plugins/http/handler_test.go
+++ b/tests/plugins/http/handler_test.go
@@ -12,7 +12,7 @@ import (
"github.com/spiral/roadrunner/v2/pkg/pool"
"github.com/spiral/roadrunner/v2/pkg/transport/pipe"
- handler2 "github.com/spiral/roadrunner/v2/pkg/worker_handler"
+ "github.com/spiral/roadrunner/v2/pkg/worker_handler"
"github.com/spiral/roadrunner/v2/plugins/http/config"
"github.com/stretchr/testify/assert"
@@ -35,7 +35,7 @@ func TestHandler_Echo(t *testing.T) {
t.Fatal(err)
}
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -66,7 +66,7 @@ func TestHandler_Echo(t *testing.T) {
}
func Test_HandlerErrors(t *testing.T) {
- _, err := handler2.NewHandler(1024, config.Uploads{
+ _, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, nil)
@@ -89,7 +89,7 @@ func TestHandler_Headers(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -150,7 +150,7 @@ func TestHandler_Empty_User_Agent(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -210,7 +210,7 @@ func TestHandler_User_Agent(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -270,7 +270,7 @@ func TestHandler_Cookies(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -335,7 +335,7 @@ func TestHandler_JsonPayload_POST(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -399,7 +399,7 @@ func TestHandler_JsonPayload_PUT(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -459,7 +459,7 @@ func TestHandler_JsonPayload_PATCH(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -519,7 +519,7 @@ func TestHandler_FormData_POST(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -592,7 +592,7 @@ func TestHandler_FormData_POST_Overwrite(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -665,7 +665,7 @@ func TestHandler_FormData_POST_Form_UrlEncoded_Charset(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -737,7 +737,7 @@ func TestHandler_FormData_PUT(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -809,7 +809,7 @@ func TestHandler_FormData_PATCH(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -881,7 +881,7 @@ func TestHandler_Multipart_POST(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -995,7 +995,7 @@ func TestHandler_Multipart_PUT(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1109,7 +1109,7 @@ func TestHandler_Multipart_PATCH(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1225,7 +1225,7 @@ func TestHandler_Error(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1271,7 +1271,7 @@ func TestHandler_Error2(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1317,7 +1317,7 @@ func TestHandler_Error3(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1, config.Uploads{
+ h, err := handler.NewHandler(1, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1376,7 +1376,7 @@ func TestHandler_ResponseDuration(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1401,7 +1401,7 @@ func TestHandler_ResponseDuration(t *testing.T) {
gotresp := make(chan interface{})
h.AddListener(func(event interface{}) {
switch t := event.(type) {
- case handler2.ResponseEvent:
+ case handler.ResponseEvent:
if t.Elapsed() > 0 {
close(gotresp)
}
@@ -1437,7 +1437,7 @@ func TestHandler_ResponseDurationDelayed(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1462,7 +1462,7 @@ func TestHandler_ResponseDurationDelayed(t *testing.T) {
gotresp := make(chan interface{})
h.AddListener(func(event interface{}) {
switch tp := event.(type) {
- case handler2.ResponseEvent:
+ case handler.ResponseEvent:
if tp.Elapsed() > time.Second {
close(gotresp)
}
@@ -1497,7 +1497,7 @@ func TestHandler_ErrorDuration(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
@@ -1522,7 +1522,7 @@ func TestHandler_ErrorDuration(t *testing.T) {
goterr := make(chan interface{})
h.AddListener(func(event interface{}) {
switch tp := event.(type) {
- case handler2.ErrorEvent:
+ case handler.ErrorEvent:
if tp.Elapsed() > 0 {
close(goterr)
}
@@ -1571,7 +1571,7 @@ func TestHandler_IP(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, cidrs, p)
@@ -1632,7 +1632,7 @@ func TestHandler_XRealIP(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, cidrs, p)
@@ -1698,7 +1698,7 @@ func TestHandler_XForwardedFor(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, cidrs, p)
@@ -1763,7 +1763,7 @@ func TestHandler_XForwardedFor_NotTrustedRemoteIp(t *testing.T) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, cidrs, p)
@@ -1811,7 +1811,7 @@ func BenchmarkHandler_Listen_Echo(b *testing.B) {
p.Destroy(context.Background())
}()
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, p)
diff --git a/tests/plugins/http/parse_test.go b/tests/plugins/http/parse_test.go
index 832ecde4..32738ae0 100644
--- a/tests/plugins/http/parse_test.go
+++ b/tests/plugins/http/parse_test.go
@@ -3,7 +3,7 @@ package http
import (
"testing"
- handler2 "github.com/spiral/roadrunner/v2/pkg/worker_handler"
+ "github.com/spiral/roadrunner/v2/pkg/worker_handler"
)
var samples = []struct {
@@ -21,7 +21,7 @@ var samples = []struct {
func Test_FetchIndexes(t *testing.T) {
for i := 0; i < len(samples); i++ {
- r := handler2.FetchIndexes(samples[i].in)
+ r := handler.FetchIndexes(samples[i].in)
if !same(r, samples[i].out) {
t.Errorf("got %q, want %q", r, samples[i].out)
}
@@ -31,7 +31,7 @@ func Test_FetchIndexes(t *testing.T) {
func BenchmarkConfig_FetchIndexes(b *testing.B) {
for _, tt := range samples {
for n := 0; n < b.N; n++ {
- r := handler2.FetchIndexes(tt.in)
+ r := handler.FetchIndexes(tt.in)
if !same(r, tt.out) {
b.Fail()
}
diff --git a/tests/plugins/http/response_test.go b/tests/plugins/http/response_test.go
index 648b6255..5b72df40 100644
--- a/tests/plugins/http/response_test.go
+++ b/tests/plugins/http/response_test.go
@@ -7,7 +7,7 @@ import (
"testing"
"github.com/spiral/roadrunner/v2/pkg/payload"
- handler2 "github.com/spiral/roadrunner/v2/pkg/worker_handler"
+ "github.com/spiral/roadrunner/v2/pkg/worker_handler"
"github.com/stretchr/testify/assert"
)
@@ -45,13 +45,13 @@ func (tw *testWriter) Push(target string, opts *http.PushOptions) error {
}
func TestNewResponse_Error(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{Context: []byte(`invalid payload`)})
+ r, err := handler.NewResponse(payload.Payload{Context: []byte(`invalid payload`)})
assert.Error(t, err)
assert.Nil(t, r)
}
func TestNewResponse_Write(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(`{"headers":{"key":["value"]},"status": 301}`),
Body: []byte(`sample body`),
})
@@ -68,7 +68,7 @@ func TestNewResponse_Write(t *testing.T) {
}
func TestNewResponse_Stream(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(`{"headers":{"key":["value"]},"status": 301}`),
})
@@ -93,7 +93,7 @@ func TestNewResponse_Stream(t *testing.T) {
}
func TestNewResponse_StreamError(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(`{"headers":{"key":["value"]},"status": 301}`),
})
@@ -114,7 +114,7 @@ func TestNewResponse_StreamError(t *testing.T) {
}
func TestWrite_HandlesPush(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(`{"headers":{"Http2-Push":["/test.js"],"content-type":["text/html"]},"status": 200}`),
})
@@ -129,7 +129,7 @@ func TestWrite_HandlesPush(t *testing.T) {
}
func TestWrite_HandlesTrailers(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(`{"headers":{"Trailer":["foo, bar", "baz"],"foo":["test"],"bar":["demo"]},"status": 200}`),
})
@@ -139,7 +139,7 @@ func TestWrite_HandlesTrailers(t *testing.T) {
w := &testWriter{h: http.Header(make(map[string][]string))}
assert.NoError(t, r.Write(w))
- assert.Nil(t, w.h[handler2.TrailerHeaderKey])
+ assert.Nil(t, w.h[handler.TrailerHeaderKey])
assert.Nil(t, w.h["foo"]) //nolint:staticcheck
assert.Nil(t, w.h["baz"]) //nolint:staticcheck
@@ -148,7 +148,7 @@ func TestWrite_HandlesTrailers(t *testing.T) {
}
func TestWrite_HandlesHandlesWhitespacesInTrailer(t *testing.T) {
- r, err := handler2.NewResponse(payload.Payload{
+ r, err := handler.NewResponse(payload.Payload{
Context: []byte(
`{"headers":{"Trailer":["foo\t,bar , baz"],"foo":["a"],"bar":["b"],"baz":["c"]},"status": 200}`),
})
diff --git a/tests/plugins/http/uploads_test.go b/tests/plugins/http/uploads_test.go
index 5381d30e..82843d4e 100644
--- a/tests/plugins/http/uploads_test.go
+++ b/tests/plugins/http/uploads_test.go
@@ -18,7 +18,7 @@ import (
j "github.com/json-iterator/go"
poolImpl "github.com/spiral/roadrunner/v2/pkg/pool"
"github.com/spiral/roadrunner/v2/pkg/transport/pipe"
- handler2 "github.com/spiral/roadrunner/v2/pkg/worker_handler"
+ "github.com/spiral/roadrunner/v2/pkg/worker_handler"
"github.com/spiral/roadrunner/v2/plugins/http/config"
"github.com/stretchr/testify/assert"
)
@@ -40,7 +40,7 @@ func TestHandler_Upload_File(t *testing.T) {
t.Fatal(err)
}
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, pool)
@@ -123,7 +123,7 @@ func TestHandler_Upload_NestedFile(t *testing.T) {
t.Fatal(err)
}
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{},
}, nil, pool)
@@ -206,7 +206,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) {
t.Fatal(err)
}
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: "-------",
Forbid: []string{},
}, nil, pool)
@@ -289,7 +289,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) {
t.Fatal(err)
}
- h, err := handler2.NewHandler(1024, config.Uploads{
+ h, err := handler.NewHandler(1024, config.Uploads{
Dir: os.TempDir(),
Forbid: []string{".go"},
}, nil, pool)