github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/utils/interceptors/curl_test.go (about)

     1  package interceptors
     2  
     3  import (
     4  	"bytes"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/livekit/protocol/livekit"
    11  )
    12  
    13  func TestCurlPrinter(t *testing.T) {
    14  	var buf bytes.Buffer
    15  	err := printCurl(&buf,
    16  		"http://localhost:8080",
    17  		"example", "Service", "Do",
    18  		http.Header{"X-Test": {"true"}},
    19  		&livekit.Room{Name: "test"},
    20  	)
    21  	require.NoError(t, err)
    22  	require.Equal(t, `curl -X POST \
    23  	-H 'X-Test: true' \
    24  	-H 'Content-Type: application/json' \
    25  	--data '{"name":"test"}' \
    26  	http://localhost:8080/twirp/example.Service/Do
    27  `, buf.String())
    28  }