mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
This PR: - moves state.go to its own module - moves the phpheaders test the phpheaders module - simplifies backoff.go - makes the backoff error instead of panic (so it can be tested) - removes some unused C structs
23 lines
733 B
Go
23 lines
733 B
Go
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(t.Context(), 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)
|
|
}
|
|
}
|