Skip to content

Commit

Permalink
fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed May 28, 2015
1 parent b01d06c commit 8a25781
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/github.com/getlantern/flashlight/logging/logging_test.go
Expand Up @@ -23,28 +23,28 @@ func TestLoggly(t *testing.T) {

log.Error("")
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Regexp(t, regexp.MustCompile("logging_test.go:([0-9]+)"), result["message"])
}

buf.Reset()
log.Error("short message")
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Regexp(t, regexp.MustCompile("logging_test.go:([0-9]+) short message"), result["message"])
}

buf.Reset()
log.Error("message with: reason")
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Regexp(t, "logging_test.go:([0-9]+) message with: reason", result["message"])
}

buf.Reset()
log.Error("deep reason: message with: reason")
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Equal(t, "message with: reason", result["message"], "message should be last 2 chunks")
}

Expand All @@ -57,15 +57,15 @@ func TestLoggly(t *testing.T) {
buf.Reset()
log.Error("deep reason: an url 127.0.0.1:8787 in message: reason")
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Equal(t, "an url 127.0.0.1:8787 in message: reason", result["message"], "should not truncate url")
}

buf.Reset()
longMsg := "message with: really l" + strings.Repeat("o", 100) + "ng reason"
log.Error(longMsg)
if assert.NoError(t, json.Unmarshal(buf.Bytes(), &result), "Unmarshal error") {
assert.Equal(t, "test", result["locationInfo"])
assert.Equal(t, "ERROR test", result["locationInfo"])
assert.Regexp(t, regexp.MustCompile("logging_test.go:([0-9]+) "+longMsg), result["message"])
}
}

0 comments on commit 8a25781

Please sign in to comment.