mirror of
https://github.com/dunglas/frankenphp
synced 2024-11-23 08:39:21 +00:00
d99b16a158
Some checks failed
Lint Code Base / Lint Code Base (push) Has been cancelled
Sanitizers / ${{ matrix.sanitizer }} (asan) (push) Has been cancelled
Sanitizers / ${{ matrix.sanitizer }} (msan) (push) Has been cancelled
Tests / tests (8.2) (push) Has been cancelled
Tests / tests (8.3) (push) Has been cancelled
Tests / tests (8.4) (push) Has been cancelled
* Removes Cgo handles and adds phpThreads. * Changes variable name. * Changes variable name. * Fixes merge error. * Removes unnecessary 'workers are done' check. * Removes panic. * Replaces int with uint32_t. * Changes index type to uintptr_t. * simplify --------- Co-authored-by: a.stecher <a.stecher@sportradar.com> Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
41 lines
886 B
Go
41 lines
886 B
Go
package frankenphp
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestInitializeTwoPhpThreadsWithoutRequests(t *testing.T) {
|
|
initPHPThreads(2)
|
|
|
|
assert.Len(t, phpThreads, 2)
|
|
assert.NotNil(t, phpThreads[0])
|
|
assert.NotNil(t, phpThreads[1])
|
|
assert.Nil(t, phpThreads[0].mainRequest)
|
|
assert.Nil(t, phpThreads[0].workerRequest)
|
|
}
|
|
|
|
func TestMainRequestIsActiveRequest(t *testing.T) {
|
|
mainRequest := &http.Request{}
|
|
initPHPThreads(1)
|
|
thread := phpThreads[0]
|
|
|
|
thread.mainRequest = mainRequest
|
|
|
|
assert.Equal(t, mainRequest, thread.getActiveRequest())
|
|
}
|
|
|
|
func TestWorkerRequestIsActiveRequest(t *testing.T) {
|
|
mainRequest := &http.Request{}
|
|
workerRequest := &http.Request{}
|
|
initPHPThreads(1)
|
|
thread := phpThreads[0]
|
|
|
|
thread.mainRequest = mainRequest
|
|
thread.workerRequest = workerRequest
|
|
|
|
assert.Equal(t, workerRequest, thread.getActiveRequest())
|
|
}
|