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: encoder_test.go
    path of file: ./repos/yq/pkg/yqlib
    
    the code of the file until where you have to start completion: //go:build !yq_nojson

package yqlib

import (
	"bufio"
	"bytes"
	"strings"
	"testing"

	"github.com/mikefarah/yq/v4/test"
)

func yamlToJSON(t *testing.T, sampleYaml string, indent int) string {
	t.Helper()
	var output bytes.Buffer
	writer := bufio.NewWriter(&output)

	prefs := ConfiguredJSONPreferences.Copy()
	prefs.Indent = indent
	prefs.UnwrapScalar = false
	var jsonEncoder = NewJSONEncoder(prefs)
	inputs, err := readDocuments(strings.NewReader(sampleYaml), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
	if err != nil {
		panic(err)
	}
	node := inputs.Front()
    
func yamlToJSON(t *testing.T, sampleYaml string, indent int) string {
	t.Helper()
	var output bytes.Buffer
	writer := bufio.NewWriter(&output)

	prefs := ConfiguredJSONPreferences.Copy()
	prefs.Indent = indent
	prefs.UnwrapScalar = false
	var jsonEncoder = NewJSONEncoder(prefs)
	inputs, err := readDocuments(strings.NewReader(sampleYaml), "sample.yml", 0, NewYamlDecoder(ConfiguredYamlPreferences))
	if err != nil {
		panic(err)
	}
	node := inputs.Front().Value.(*CandidateNode)
	log.Debugf("%v", NodeToString(node))
	// log.Debugf("Content[0] %v", NodeToString(node.Content[0]))

	err = jsonEncoder.Encode(writer, node)
	if err != nil {
		panic(err)
	}
	writer.Flush()

	return strings.TrimSuffix(output.String(), "\n")
}