Files
gotsrpc/example/basic/main_test.go
Kevin Franklin Kim df7a09dd76 style: wsl_v5
2026-03-22 21:34:08 +01:00

29 lines
570 B
Go

package main_test
import (
"context"
"net/http/httptest"
"testing"
"time"
"github.com/foomo/gotsrpc/v2/example/basic/service"
"github.com/stretchr/testify/assert"
)
func TestContextCanceled(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
go func() {
time.Sleep(time.Second)
cancel()
}()
svr := httptest.NewServer(service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}))
defer svr.Close()
client := service.NewDefaultServiceGoTSRPCClient(svr.URL)
clientErr := client.Context(ctx)
assert.ErrorIs(t, clientErr, context.Canceled)
}