func prepRepeatDataTestsQueryString(request *genproto.RepeatRequest, exclude map[string]bool) string {
	return prepQueryString(prepRepeatDataTestsQueryParams(request, exclude, queryStringLowerCamelCaser))
}
prepRepeatDataTestsQueryString returns the query string containing all fields in `request.info`
except for those whose proto name (relative to request.info) are present in the `exclude` map
with a value of `true`.
package main
import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"net/url"
	"path/filepath"
	"runtime"
	"strings"
	"testing"
	"github.com/google/go-cmp/cmp"
	"github.com/googleapis/gapic-showcase/server/genproto"
	pb "github.com/googleapis/gapic-showcase/server/genproto"
	"github.com/googleapis/gapic-showcase/server/services"
	"github.com/googleapis/gapic-showcase/util/genrest/resttools"
	"github.com/iancoleman/strcase"
	"google.golang.org/protobuf/encoding/protojson"
	"google.golang.org/protobuf/proto"
)
func TestComplianceSuite(t *testing.T) {
	suite, server, err := complianceSuiteTestSetup()
	if err != nil {
		t.Fatal(err)
	}
	server.Start()
	defer server.Close()
	resttools.JSONMarshaler.Replace(nil)
	defer resttools.JSONMarshaler.Restore()
	restRPCs := map[string]prepRepeatDataTestFunc{
		"Compliance.RepeatDataBody":                 prepRepeatDataBodyTest,
		"Compliance.RepeatDataBodyPut":              prepRepeatDataBodyPutTest,
		"Compliance.RepeatDataBodyPatch":            prepRepeatDataBodyPatchTest,
		"Compliance.RepeatDataBodyInfo":             prepRepeatDataBodyInfoTest,
		"Compliance.RepeatDataQuery":                prepRepeatDataQueryTest,
		"Compliance.RepeatDataSimplePath":           prepRepeatDataSimplePathTest,
		"Compliance.RepeatDataPathResource":         prepRepeatDataPathResourceTest,
		"Compliance.RepeatDataPathTrailingResource": prepRepeatDataPathTrailingResourceTest,
	}
	for _, group := range suite.GetGroup() {
		rpcsToTest := group.GetRpcs()
		for requestIdx, requestProto := range group.GetRequests() {
			for rpcIdx, rpcName := range rpcsToTest {
				errorPrefix := fmt.Sprintf("[request %d/%q: rpc %q/%d/%q]",
					requestIdx, requestProto.GetName(), group.Name, rpcIdx, rpcName)
				rpcPrep, ok := restRPCs[rpcName]
				if !ok {
					t.Errorf("%s could not find prep function for this RPC", errorPrefix)
					continue
				}
				verb, prepName, path, requestBody, err := rpcPrep(requestProto)
				if err != nil {
					t.Errorf("%s error: %s", errorPrefix, err)
				}
				if got, want := prepName, rpcName; got != want {
					t.Errorf("%s retrieved mismatched prep function: got %q, want %q", errorPrefix, got, want)
				}
				httpRequest, err := http.NewRequest(verb, server.URL+path, strings.NewReader(requestBody))
				if err != nil {
					t.Errorf("%s error creating request: %s", errorPrefix, err)
					continue
				}
				resttools.PopulateRequestHeaders(httpRequest)
				httpResponse, err := http.DefaultClient.Do(httpRequest)
				if err != nil {
					t.Errorf("%s error issuing call: %s", errorPrefix, err)
					continue
				}
				if got, want := httpResponse.StatusCode, http.StatusOK; got != want {
					t.Errorf("%s response code: got %d, want %d\n   %s %s\n\n",
						errorPrefix, got, want, verb, server.URL+path)
				}
				responseBody, err := ioutil.ReadAll(httpResponse.Body)
				httpResponse.Body.Close()
				if err != nil {
					t.Errorf("%s could not read httpResponse body: %s", errorPrefix, err)
					continue
				}
				var response genproto.RepeatResponse
				if err := protojson.Unmarshal(responseBody, &response); err != nil {
					t.Errorf("%s could not unmarshal httpResponse body: %s\n   response body: %s\n   request: %s\n",
						errorPrefix, err, string(responseBody), requestBody)
					continue
				}
				if diff := cmp.Diff(response.GetRequest(), requestProto, cmp.Comparer(proto.Equal)); diff != "" {
					t.Errorf("%s unexpected response: got=-, want=+:%s\n   %s %s\n------------------------------\n",
						errorPrefix, diff, verb, server.URL+path)
				}
			}
		}
	}
}
func TestComplianceSuiteLoadedf(t *testing.T) {
	if services.ComplianceSuiteStatus != services.ComplianceSuiteLoaded {
		t.Fatalf("embedded compliance suite was not loaded: status %#v %s", services.ComplianceSuiteStatus, services.ComplianceSuiteStatusMessage)
	}
	suite, err := getCleanComplianceSuite()
	if err != nil {
		t.Fatal(err)
	}
	if diff := cmp.Diff(suite, services.ComplianceSuite, cmp.Comparer(proto.Equal)); diff != "" {
		t.Errorf("embedded compliance suite does not match released suite at %q", complianceSuiteFileName)
	}
}
type prepRepeatDataTestFunc func(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error)
func prepRepeatDataBodyTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataBody"
	bodyBytes, err := resttools.ToJSON().Marshal(request)
	return "POST", name, "/v1beta1/repeat:body", string(bodyBytes), err
}
func prepRepeatDataBodyPutTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	_, _, path, body, err = prepRepeatDataBodyTest(request)
	return "PUT", "Compliance.RepeatDataBodyPut", path + "put", body, err
}
func prepRepeatDataBodyPatchTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	_, _, path, body, err = prepRepeatDataBodyTest(request)
	return "PATCH", "Compliance.RepeatDataBodyPatch", path + "patch", body, err
}
func prepRepeatDataBodyInfoTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataBodyInfo"
	bodyBytes, err := resttools.ToJSON().Marshal(request.Info)
	queryString := prepRepeatDataTestsQueryString(request, map[string]bool{"info": true})
	_ = bodyBytes
	return "POST", name, "/v1beta1/repeat:bodyinfo" + queryString, string(bodyBytes), err
}
func prepRepeatDataQueryTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataQuery"
	queryString := prepRepeatDataTestsQueryString(request, nil)
	return "GET", name, "/v1beta1/repeat:query" + queryString, body, err
}
func prepRepeatDataSimplePathTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataSimplePath"
	info := request.GetInfo()
	pathParts := []string{}
	nonQueryParamNames := map[string]bool{}
	for _, part := range []struct {
		name   string
		format string
		value  interface{}
	}{
		{"f_string", "%s", info.GetFString()},
		{"f_int32", "%d", info.GetFInt32()},
		{"f_double", "%g", info.GetFDouble()},
		{"f_bool", "%t", info.GetFBool()},
		{"f_kingdom", "%s", info.GetFKingdom()},
	} {
		pathParts = append(pathParts, url.PathEscape(fmt.Sprintf(part.format, part.value)))
		nonQueryParamNames["info."+part.name] = true
	}
	path = fmt.Sprintf("/v1beta1/repeat/%s:simplepath", strings.Join(pathParts, "/"))
	queryString := prepRepeatDataTestsQueryString(request, nonQueryParamNames)
	return "GET", name, path + queryString, body, err
}
func prepRepeatDataPathResourceTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataPathResource"
	info := request.GetInfo()
	pathParts := []string{}
	nonQueryParamNames := map[string]bool{}
	for _, part := range []struct {
		name           string
		format         string
		value          interface{}
		requiredPrefix string
	}{
		{"f_string", "%s", info.GetFString(), "first/"},
		{"f_child.f_string", "%s", info.GetFChild().GetFString(), "second/"},
		{"f_bool", "bool/%t", info.GetFBool(), ""},
	} {
		if len(part.requiredPrefix) > 0 && !strings.HasPrefix(part.value.(string), part.requiredPrefix) {
			err = fmt.Errorf("expected value of %q to begin with %q; got %q", part.name, part.requiredPrefix, part.value)
			return
		}
		pathParts = append(pathParts, url.PathEscape(fmt.Sprintf(part.format, part.value)))
		nonQueryParamNames["info."+part.name] = true
	}
	path = fmt.Sprintf("/v1beta1/repeat/%s:pathresource", strings.Join(pathParts, "/"))
	queryString := prepRepeatDataTestsQueryString(request, nonQueryParamNames)
	return "GET", name, path + queryString, body, err
}
func prepRepeatDataPathTrailingResourceTest(request *genproto.RepeatRequest) (verb string, name string, path string, body string, err error) {
	name = "Compliance.RepeatDataPathTrailingResource"
	info := request.GetInfo()
	pathParts := []string{}
	nonQueryParamNames := map[string]bool{}
	for _, part := range []struct {
		name           string
		format         string
		value          interface{}
		requiredPrefix string
	}{
		{"f_string", "%s", info.GetFString(), "first/"},
		{"f_child.f_string", "%s", info.GetFChild().GetFString(), "second/"},
	} {
		if len(part.requiredPrefix) > 0 && !strings.HasPrefix(part.value.(string), part.requiredPrefix) {
			err = fmt.Errorf("expected value of %q to begin with %q; got %q", part.name, part.requiredPrefix, part.value)
			return
		}
		pathParts = append(pathParts, url.PathEscape(fmt.Sprintf(part.format, part.value)))
		nonQueryParamNames["info."+part.name] = true
	}
	path = fmt.Sprintf("/v1beta1/repeat/%s:pathtrailingresource", strings.Join(pathParts, "/"))
	queryString := prepRepeatDataTestsQueryString(request, nonQueryParamNames)
	return "GET", name, path + queryString, body, err
}