<commit_before>package client

import (
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"net/url"
	"strconv"
	"strings"
	"testing"

	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
)

var (
	mux           *http.ServeMux
	server        *httptest.Server
	fakeUAAServer *httptest.Server
)

type MockRoute struct {
	Method      string
	Endpoint    string
	Output      []string
	UserAgent   string
	Status      int
	QueryString string
	PostForm    *string
}

type MockRouteWithRedirect struct {
	MockRoute
	RedirectLocation string
}

func setup(mock MockRoute, t *testing.T) {
	setupMultiple([]MockRoute{mock}, t)
}

func testQueryString(QueryString string, QueryStringExp string, t *testing.T) {
	t.Helper()
	if QueryStringExp == "" {
		return
	}

	value, _ := url.QueryUnescape(QueryString)
	if QueryStringExp != value {
		t.Errorf("Error: Query string '%s' should be equal to '%s'", QueryStringExp, value)
	}
}

func testUserAgent(UserAgent string, UserAgentExp string, t *testing.T) {
	t.Helper()
	if len(UserAgentExp) < 1 {
		UserAgentExp = "Go-CF-client/1.1"
	}
	if UserAgent != UserAgentExp {
		t.Errorf("Error: Agent %s should be equal to %s", UserAgent, UserAgentExp)
	}
}

func testReqBody(req *http.Request, postFormBody *string, t *testing.T) {<commit_msg>Fix broken test with new user agent string<commit_after>package client

import (
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"net/url"
	"strconv"
	"strings"
	"testing"

	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
)

var (
	mux           *http.ServeMux
	server        *httptest.Server
	fakeUAAServer *httptest.Server
)

type MockRoute struct {
	Method      string
	Endpoint    string
	Output      []string
	UserAgent   string
	Status      int
	QueryString string
	PostForm    *string
}

type MockRouteWithRedirect struct {
	MockRoute
	RedirectLocation string
}

func setup(mock MockRoute, t *testing.T) {
	setupMultiple([]MockRoute{mock}, t)
}

func testQueryString(QueryString string, QueryStringExp string, t *testing.T) {
	t.Helper()
	if QueryStringExp == "" {
		return
	}

	value, _ := url.QueryUnescape(QueryString)
	if QueryStringExp != value {
		t.Errorf("Error: Query string '%s' should be equal to '%s'", QueryStringExp, value)
	}
}

func testUserAgent(UserAgent string, UserAgentExp string, t *testing.T) {
	t.Helper()
	if len(UserAgentExp) < 1 {
		UserAgentExp = "Go-CF-client/2.0"
	}
	if UserAgent != UserAgentExp {
		t.Errorf("Error: Agent %s should be equal to %s", UserAgent, UserAgentExp)
	}
}

func testReqBody(req *http.Request, postFormBody *string, t *testing.T) {
{'fraction_non_alphanumeric': 0.11791907514450867, 'fraction_numerical': 0.0023121387283236996, 'mean_word_length': 3.9166666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '869376', 'n_tokens_mistral': 940, 'n_tokens_neox': 925, 'n_words': 225}