|
|
@@ -51,20 +51,9 @@ func TestStatsTestSuite(t *testing.T) {
|
|
|
|
|
|
func (suite *StatsTestSuite) SetupTest() {
|
|
|
|
|
|
- // Set a regexp for the httpClient to ensure it at least records "(OTHER)" domain bytes
|
|
|
- regexp, _ := regexp.Compile(`^[a-z0-9\.]*\.(example\.com)$`)
|
|
|
- replace := "$1"
|
|
|
- regexps := Regexps{regexpReplace{regexp: regexp, replace: replace}}
|
|
|
-
|
|
|
suite.serverID = fmt.Sprintf("%s-%d", _SERVER_ID, nextServerID)
|
|
|
nextServerID++
|
|
|
suite.httpClient = &http.Client{
|
|
|
- Transport: &http.Transport{
|
|
|
- Dial: makeStatsDialer(suite.serverID, ®exps),
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
- suite.httpClientNoRegexes = &http.Client{
|
|
|
Transport: &http.Transport{
|
|
|
Dial: makeStatsDialer(suite.serverID, &Regexps{}),
|
|
|
},
|
|
|
@@ -135,6 +124,18 @@ func (suite *StatsTestSuite) Test_TakeOutStatsForServer() {
|
|
|
}
|
|
|
|
|
|
func (suite *StatsTestSuite) Test_PutBackStatsForServer() {
|
|
|
+
|
|
|
+ // Set a regexp for the httpClient to ensure it at least records "(OTHER)" domain bytes;
|
|
|
+ // The regex is set to "nomatch.com" so that it _will_ exercise the "(OTHER)" case.
|
|
|
+ regexp, _ := regexp.Compile(`^[a-z0-9\.]*\.(nomatch\.com)$`)
|
|
|
+ replace := "$1"
|
|
|
+ regexps := &Regexps{regexpReplace{regexp: regexp, replace: replace}}
|
|
|
+ suite.httpClient = &http.Client{
|
|
|
+ Transport: &http.Transport{
|
|
|
+ Dial: makeStatsDialer(suite.serverID, regexps),
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
resp, err := suite.httpClient.Get("http://example.com/index.html")
|
|
|
suite.Nil(err, "need successful http to proceed with tests")
|
|
|
resp.Body.Close()
|
|
|
@@ -156,10 +157,17 @@ func (suite *StatsTestSuite) Test_PutBackStatsForServer() {
|
|
|
|
|
|
func (suite *StatsTestSuite) Test_NoRegexes() {
|
|
|
|
|
|
+ // Set no regexps for the httpClient
|
|
|
+ suite.httpClient = &http.Client{
|
|
|
+ Transport: &http.Transport{
|
|
|
+ Dial: makeStatsDialer(suite.serverID, &Regexps{}),
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
// Ensure there are no stats before making the no-regex request
|
|
|
_ = TakeOutStatsForServer(suite.serverID)
|
|
|
|
|
|
- resp, err := suite.httpClientNoRegexes.Get("http://example.com/index.html")
|
|
|
+ resp, err := suite.httpClient.Get("http://example.com/index.html")
|
|
|
suite.Nil(err, "need successful http to proceed with tests")
|
|
|
resp.Body.Close()
|
|
|
|