mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
Also moves php_headers test.
This commit is contained in:
22
internal/phpheaders/phpheaders_test.go
Normal file
22
internal/phpheaders/phpheaders_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package phpheaders
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAllCommonHeadersAreCorrect(t *testing.T) {
|
||||
fakeRequest := httptest.NewRequest("GET", "http://localhost", nil)
|
||||
|
||||
for header, phpHeader := range CommonRequestHeaders {
|
||||
// verify that common and uncommon headers return the same result
|
||||
expectedPHPHeader := GetUnCommonHeader(header)
|
||||
assert.Equal(t, phpHeader+"\x00", expectedPHPHeader, "header is not well formed: "+phpHeader)
|
||||
|
||||
// net/http will capitalize lowercase headers, verify that headers are capitalized
|
||||
fakeRequest.Header.Add(header, "foo")
|
||||
assert.Contains(t, fakeRequest.Header, header, "header is not correctly capitalized: "+header)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/dunglas/frankenphp/internal/phpheaders"
|
||||
"github.com/dunglas/frankenphp/internal/state"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -237,20 +236,6 @@ func allPossibleTransitions(worker1Path string, worker2Path string) []func(*phpT
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllCommonHeadersAreCorrect(t *testing.T) {
|
||||
fakeRequest := httptest.NewRequest("GET", "http://localhost", nil)
|
||||
|
||||
for header, phpHeader := range phpheaders.CommonRequestHeaders {
|
||||
// verify that common and uncommon headers return the same result
|
||||
expectedPHPHeader := phpheaders.GetUnCommonHeader(header)
|
||||
assert.Equal(t, phpHeader+"\x00", expectedPHPHeader, "header is not well formed: "+phpHeader)
|
||||
|
||||
// net/http will capitalize lowercase headers, verify that headers are capitalized
|
||||
fakeRequest.Header.Add(header, "foo")
|
||||
assert.Contains(t, fakeRequest.Header, header, "header is not correctly capitalized: "+header)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCorrectThreadCalculation(t *testing.T) {
|
||||
maxProcs := runtime.GOMAXPROCS(0) * 2
|
||||
oneWorkerThread := []workerOpt{{num: 1}}
|
||||
|
||||
Reference in New Issue
Block a user