You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: curl_test.go
    path of file: ./repos/gout/export
    
    the code of the file until where you have to start completion: package export

import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"os"
	"strings"
	"testing"

	"github.com/gin-gonic/gin"
	"github.com/guonaihong/gout/core"
	"github.com/guonaihong/gout/dataflow"
	"github.com/stretchr/testify/assert"
)

const (
	testCurlHeader = 1 << iota
	testCurlForm
	testCurlQuery
	testLong
	testJSON
)

const noPortExists = 12345

type testCurl struct {
	flags int
	need  string
}

// 测试生成curl命令
func Test_Curl(t *testing.T) {

	tests := []testCurl{
		{testCurlHeader | testCurlQuery | testCurlForm, `curl -X POST -H "H1:hv1" -H "H2:hv2" -F "mode=A" -F "text=good" -F "voice=@./voice.pcm" "http://www.qq.com?q1=qv1&q2=qv2"`},
		{testCurlHeader, `curl -X POST -H "H1:hv1" -H "H2:hv2" "http://www.qq.com"`},

		{testCurlHeader | testCurlQuery, `curl -X POST -H "H1:hv1" -H "H2:hv2" "http://www.qq.com?q1=qv1&
    
func Test_Curl_GenAndSend(t *testing.T) {
	// test ok
	type testData struct {
		A string
		B string
	}

	yes := false
	router := func(b *bool) *gin.Engine {
		router := gin.Default()

		router.POST("/test.json", func(c *gin.Context) {
			test := testData{}
			assert.NoError(t, c.BindJSON(&test))
			*b = true
			c.JSON(200, gin.H{"1": "1"})
		})

		return router
	}(&yes)

	ts := httptest.NewServer(http.HandlerFunc(router.ServeHTTP))

	var out strings.Builder
	err := dataflow.POST(ts.URL + "/test.json").SetJSON(core.H{"a": "a", "b": "b"}).Export().Curl().SetOutput(&out).GenAndSend().Do()
	assert.NoError(t, err)
	assert.Equal(t, yes, true)
	need := fmt.Sprintf(`curl -X POST -H "Content-Type:application/json" -d "{\"a\":\"a\",\"b\":\"b\"}" "%s/test.json"`, ts.URL)

	assert.Equal(t, need, strings.TrimSpace(out.String()))

	// ==================================
	// test fail
	tests := []dataflow.Curl{
		dataflow.POST(fmt.Sprintf(":%d/test.json", noPortExists)).SetJSON(core.H{"a": "a", "b": "b"}).Export().Curl().GenAndSend(),
		dataflow.POST(ts.URL + "/test.json").Debug(true).SetJSON(core.H{"a": "a", "b": "b"}).BindBody(&testData{}).Export().Curl().GenAndSend(),
		dataflow.POST(ts.URL + "/test.json").Debug(true).SetBody(&testData{}).BindBody(&testData{}).Export().Curl().GenAndSend(),
	}

	for _, v := range tests {
		err := v.Do()
		assert.Error(t, err)
	}
}