mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
fixing on asset equal and not equal + logger and tracker test update
This commit is contained in:
parent
a98292a0d0
commit
7679a5c4f7
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/bxcodec/faker/v3"
|
||||
)
|
||||
@ -111,3 +112,19 @@ func MakeTestApiRequest(apiUrl string, content interface{}, token string) (map[s
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func AssertEqual(t *testing.T, testName string, actual string, expected string) {
|
||||
if expected != actual {
|
||||
t.Errorf("%v failed expected %v, got %v", testName, expected, actual)
|
||||
} else {
|
||||
t.Logf("%v success expected %v, got %v", testName, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertNotEqual(t *testing.T, testName string, actual string, expected string) {
|
||||
if expected == actual {
|
||||
t.Errorf("%v failed expected different value %v, got %v", testName, expected, actual)
|
||||
} else {
|
||||
t.Logf("%v success expected different value %v, got %v", testName, expected, actual)
|
||||
}
|
||||
}
|
||||
|
@ -46,11 +46,7 @@ func TestApplicationLogIDRequired(t *testing.T) {
|
||||
|
||||
setupResponse := Init(option)
|
||||
|
||||
if fmt.Sprint(setupResponse) != expectedResponse {
|
||||
t.Errorf("TestApplicationLogIDRequired failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
} else {
|
||||
t.Logf("TestApplicationLogIDRequired success expected %v, got %v", expectedResponse, setupResponse)
|
||||
}
|
||||
AssertEqual(t, "TestApplicationLogIDRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
}
|
||||
func TestApplicationLogKeyRequired(t *testing.T) {
|
||||
expectedResponse := ErrApplicationLogKeyMissing
|
||||
@ -62,11 +58,8 @@ func TestApplicationLogKeyRequired(t *testing.T) {
|
||||
|
||||
setupResponse := Init(option)
|
||||
|
||||
if fmt.Sprint(setupResponse) != expectedResponse {
|
||||
t.Errorf("TestApplicationLogKeyRequired failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
} else {
|
||||
t.Logf("TestApplicationLogKeyRequired success expected %v, got %v", expectedResponse, setupResponse)
|
||||
}
|
||||
AssertEqual(t, "TestApplicationLogKeyRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
func TestValidContentRequired(t *testing.T) {
|
||||
expectedResponse := ErrContentMissing
|
||||
@ -79,17 +72,15 @@ func TestValidContentRequired(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestValidContentRequired failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestValidContentRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
}
|
||||
var tag = []string{}
|
||||
|
||||
logResponse, logErr := LogInfo(nil, tag)
|
||||
fmt.Sprint(logResponse)
|
||||
if fmt.Sprint(logErr) == expectedResponse {
|
||||
t.Logf("TestValidContentRequired failed expected %v, got %v", expectedResponse, logErr)
|
||||
} else {
|
||||
t.Errorf("TestValidContentRequired failed expected %v, got %v", expectedResponse, logErr)
|
||||
}
|
||||
|
||||
AssertEqual(t, "TestValidContentRequired", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
func TestContentRequired(t *testing.T) {
|
||||
expectedResponse := "Content to be logged is required."
|
||||
@ -102,7 +93,7 @@ func TestContentRequired(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentRequired failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
}
|
||||
var tag = []string{}
|
||||
|
||||
@ -110,14 +101,11 @@ func TestContentRequired(t *testing.T) {
|
||||
actualResponse := logResponse.Message
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentRequired failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentRequired", fmt.Sprint(logErr), expectedResponse)
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentRequired failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentRequired success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentRequired", actualResponse, expectedResponse)
|
||||
|
||||
}
|
||||
func TestValidApplicationLogRequired(t *testing.T) {
|
||||
expectedResponse := "Application Log does not exist."
|
||||
@ -130,7 +118,7 @@ func TestValidApplicationLogRequired(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestValidApplicationLogRequired failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestValidApplicationLogRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := "Sample Content"
|
||||
@ -139,14 +127,11 @@ func TestValidApplicationLogRequired(t *testing.T) {
|
||||
actualResponse := logResponse.Message
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestValidApplicationLogRequired failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestValidApplicationLogRequired", fmt.Sprint(logErr), expectedResponse)
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestValidApplicationLogRequired failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestValidApplicationLogRequired success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestValidApplicationLogRequired", actualResponse, expectedResponse)
|
||||
|
||||
}
|
||||
func TestContentStringIsLogged(t *testing.T) {
|
||||
expectedResponse := ""
|
||||
@ -159,7 +144,8 @@ func TestContentStringIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentStringIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := "Sample Content"
|
||||
@ -169,10 +155,11 @@ func TestContentStringIsLogged(t *testing.T) {
|
||||
actualResponse := logResponse.Content
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentStringIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
if expectedResponse != actualResponse {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentStringIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
@ -189,7 +176,8 @@ func TestContentStructIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentStructIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := GetSampleLog()
|
||||
@ -199,14 +187,16 @@ func TestContentStructIsLogged(t *testing.T) {
|
||||
actualResponse := logResponse.Content.(map[string]interface{})["name"]
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentStructIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentStringIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
if expectedResponse != actualResponse {
|
||||
t.Errorf("TestContentStructIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentStringIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
t.Logf("TestContentStructIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestContentOfTypeWarningIsLogged(t *testing.T) {
|
||||
@ -220,7 +210,8 @@ func TestContentOfTypeWarningIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentOfTypeWarningIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentOfTypeWarningIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := "Sample Content"
|
||||
@ -229,14 +220,12 @@ func TestContentOfTypeWarningIsLogged(t *testing.T) {
|
||||
actualResponse := logResponse.Type
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentOfTypeWarningIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentOfTypeWarningIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentOfTypeWarningIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentOfTypeWarningIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentOfTypeWarningIsLogged", actualResponse, expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
func TestContentOfTypeErrorIsLogged(t *testing.T) {
|
||||
@ -250,7 +239,8 @@ func TestContentOfTypeErrorIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentOfTypeErrorIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentOfTypeErrorIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := GetSampleLog()
|
||||
@ -259,17 +249,15 @@ func TestContentOfTypeErrorIsLogged(t *testing.T) {
|
||||
actualResponse := logResponse.Type
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentOfTypeErrorIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentOfTypeErrorIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentOfTypeErrorIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentOfTypeErrorIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentOfTypeErrorIsLogged", actualResponse, expectedResponse)
|
||||
|
||||
}
|
||||
func TestContentWithNoTagIsLogged(t *testing.T) {
|
||||
expectedResponse := 0
|
||||
expectedResponse := "0"
|
||||
option := LoggerOptions{
|
||||
ApplicationLogId: appLog["_id"].(string),
|
||||
ApplicationLogKey: appLog["key"].(string),
|
||||
@ -279,7 +267,8 @@ func TestContentWithNoTagIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentWithNoTagIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentWithNoTagIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{}
|
||||
randomContent := GetSampleLog()
|
||||
@ -288,17 +277,15 @@ func TestContentWithNoTagIsLogged(t *testing.T) {
|
||||
actualResponse := len(logResponse.Tags)
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentWithNoTagIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentWithNoTagIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentWithNoTagIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentWithNoTagIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentWithNoTagIsLogged", fmt.Sprint(actualResponse), expectedResponse)
|
||||
|
||||
}
|
||||
func TestContentWithOneTagIsLogged(t *testing.T) {
|
||||
expectedResponse := 1
|
||||
expectedResponse := "1"
|
||||
option := LoggerOptions{
|
||||
ApplicationLogId: appLog["_id"].(string),
|
||||
ApplicationLogKey: appLog["key"].(string),
|
||||
@ -308,7 +295,8 @@ func TestContentWithOneTagIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentWithOneTagIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentWithOneTagIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{"randon tag"}
|
||||
randomContent := GetSampleLog()
|
||||
@ -317,17 +305,15 @@ func TestContentWithOneTagIsLogged(t *testing.T) {
|
||||
actualResponse := len(logResponse.Tags)
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentWithOneTagIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentWithOneTagIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentWithOneTagIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentWithOneTagIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentWithOneTagIsLogged", fmt.Sprint(actualResponse), expectedResponse)
|
||||
|
||||
}
|
||||
func TestContentWithFourTagIsLogged(t *testing.T) {
|
||||
expectedResponse := 4
|
||||
expectedResponse := "4"
|
||||
expectedTypeResponse := "warning"
|
||||
option := LoggerOptions{
|
||||
ApplicationLogId: appLog["_id"].(string),
|
||||
@ -338,7 +324,8 @@ func TestContentWithFourTagIsLogged(t *testing.T) {
|
||||
setupResponse := Init(option)
|
||||
|
||||
if setupResponse != nil {
|
||||
t.Errorf("TestContentWithFourTagIsLogged failed expected %v, got %v", expectedResponse, setupResponse)
|
||||
AssertEqual(t, "TestContentWithFourTagIsLogged", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
var tag = []string{"testing", "rubylansh", "trial", "correct"}
|
||||
randomContent := GetSampleLog()
|
||||
@ -348,17 +335,11 @@ func TestContentWithFourTagIsLogged(t *testing.T) {
|
||||
actualTypeResponse := logResponse.Type
|
||||
|
||||
if logErr != nil {
|
||||
t.Errorf("TestContentWithFourTagIsLogged failed expected %v, got %v", expectedResponse, logErr)
|
||||
AssertEqual(t, "TestContentWithFourTagIsLogged", fmt.Sprint(logErr), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
if actualResponse != expectedResponse {
|
||||
t.Errorf("TestContentWithFourTagIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentWithFourTagIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
if actualTypeResponse != expectedTypeResponse {
|
||||
t.Errorf("TestContentWithFourTagIsLogged failed expected %v, got %v", expectedResponse, actualResponse)
|
||||
} else {
|
||||
t.Logf("TestContentWithFourTagIsLogged success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
AssertEqual(t, "TestContentWithFourTagIsLogged", fmt.Sprint(actualResponse), expectedResponse)
|
||||
AssertEqual(t, "TestContentWithFourTagIsLogged", actualTypeResponse, expectedTypeResponse)
|
||||
|
||||
}
|
||||
|
@ -66,23 +66,7 @@ func TestTakeInCustomTimelineEvent(t *testing.T) {
|
||||
|
||||
actualResponse := currentTimeline[0].Category
|
||||
|
||||
assertEqual(t, "TestTakeInCustomTimelineEvent", fmt.Sprint(actualResponse), expectedResponse)
|
||||
}
|
||||
|
||||
func assertEqual(t *testing.T, testName string, actual string, expected string) {
|
||||
if expected != actual {
|
||||
t.Errorf("%v failed expected %v, got %v", testName, expected, actual)
|
||||
} else {
|
||||
t.Logf("%v success expected %v, got %v", testName, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func assertNotEqual(t *testing.T, testName string, actual string, expected string) {
|
||||
if expected == actual {
|
||||
t.Errorf("%v failed expected different value %v, got %v", testName, expected, actual)
|
||||
} else {
|
||||
t.Logf("%v success expected different value %v, got %v", testName, expected, actual)
|
||||
}
|
||||
AssertEqual(t, "TestTakeInCustomTimelineEvent", fmt.Sprint(actualResponse), expectedResponse)
|
||||
}
|
||||
|
||||
func TestPositiveTimelineIsRequired(t *testing.T) {
|
||||
@ -99,7 +83,7 @@ func TestPositiveTimelineIsRequired(t *testing.T) {
|
||||
|
||||
setupResponse := InitTracker(option)
|
||||
|
||||
assertEqual(t, "TestPositiveTimelineIsRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
AssertEqual(t, "TestPositiveTimelineIsRequired", fmt.Sprint(setupResponse), expectedResponse)
|
||||
|
||||
}
|
||||
func TestCustomTimelineContainsimeStamp(t *testing.T) {
|
||||
@ -123,7 +107,7 @@ func TestCustomTimelineContainsimeStamp(t *testing.T) {
|
||||
|
||||
actualResponse := reflect.TypeOf(currentTimeline[0].Timestamp).String()
|
||||
|
||||
assertEqual(t, "TestCustomTimelineContainsimeStamp", fmt.Sprint(actualResponse), expectedResponse)
|
||||
AssertEqual(t, "TestCustomTimelineContainsimeStamp", fmt.Sprint(actualResponse), expectedResponse)
|
||||
}
|
||||
func TestCustomTimelineContainsEventId(t *testing.T) {
|
||||
|
||||
@ -146,7 +130,7 @@ func TestCustomTimelineContainsEventId(t *testing.T) {
|
||||
|
||||
actualResponse := reflect.TypeOf(currentTimeline[0].EventId).String()
|
||||
|
||||
assertEqual(t, "TestCustomTimelineContainsEventId", fmt.Sprint(actualResponse), expectedResponse)
|
||||
AssertEqual(t, "TestCustomTimelineContainsEventId", fmt.Sprint(actualResponse), expectedResponse)
|
||||
}
|
||||
|
||||
func TestTwoTimelineContainsSameEventId(t *testing.T) {
|
||||
@ -175,7 +159,7 @@ func TestTwoTimelineContainsSameEventId(t *testing.T) {
|
||||
|
||||
actualResponse := currentTimeline[1].EventId
|
||||
|
||||
assertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualResponse), expectedResponse)
|
||||
AssertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualResponse), expectedResponse)
|
||||
}
|
||||
|
||||
func TestOlderTimelineAreDiscarded(t *testing.T) {
|
||||
@ -212,9 +196,9 @@ func TestOlderTimelineAreDiscarded(t *testing.T) {
|
||||
actualFirstTimelineResponse := currentTimeline[0].Category
|
||||
actualSecondTimelineResponse := currentTimeline[1].Type
|
||||
|
||||
assertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualFirstTimelineResponse), expectedFirstTimelineResponse)
|
||||
AssertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualFirstTimelineResponse), expectedFirstTimelineResponse)
|
||||
|
||||
assertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualSecondTimelineResponse), expectedSecondTimelineResponse)
|
||||
AssertEqual(t, "TestTwoTimelineContainsSameEventId", fmt.Sprint(actualSecondTimelineResponse), expectedSecondTimelineResponse)
|
||||
|
||||
}
|
||||
func TestTagIsAdded(t *testing.T) {
|
||||
@ -241,7 +225,7 @@ func TestTagIsAdded(t *testing.T) {
|
||||
|
||||
actualResponse := tags[0].Key
|
||||
|
||||
assertEqual(t, "TestTagIsAdded", fmt.Sprint(actualResponse), expectedResponse)
|
||||
AssertEqual(t, "TestTagIsAdded", fmt.Sprint(actualResponse), expectedResponse)
|
||||
|
||||
}
|
||||
|
||||
@ -276,7 +260,7 @@ func TestTagsAreAdded(t *testing.T) {
|
||||
} else {
|
||||
t.Logf("TestTagsAreAdded success expected %v, got %v", expectedResponse, actualResponse)
|
||||
}
|
||||
assertEqual(t, "TestTagIsAdded", fmt.Sprint(actualResponse), fmt.Sprint(expectedResponse))
|
||||
AssertEqual(t, "TestTagIsAdded", fmt.Sprint(actualResponse), fmt.Sprint(expectedResponse))
|
||||
|
||||
}
|
||||
func TestOverwriteTagsWithSameKeyWhenAdded(t *testing.T) {
|
||||
@ -305,16 +289,12 @@ func TestOverwriteTagsWithSameKeyWhenAdded(t *testing.T) {
|
||||
SetTag("location", expectedResponse)
|
||||
|
||||
availableTags := GetTag()
|
||||
for _, tag := range availableTags {
|
||||
fmt.Printf("tag is %+v", tag)
|
||||
|
||||
}
|
||||
|
||||
actualResponse := availableTags[0].Value // latest value for that tag location
|
||||
|
||||
assertEqual(t, "TestOverwriteTagsWithSameKeyWhenAdded", fmt.Sprint(len(tags)), fmt.Sprint(len(availableTags))) // only 3 unique tags
|
||||
AssertEqual(t, "TestOverwriteTagsWithSameKeyWhenAdded", fmt.Sprint(len(tags)), fmt.Sprint(len(availableTags))) // only 3 unique tags
|
||||
|
||||
assertEqual(t, "TestOverwriteTagsWithSameKeyWhenAdded", actualResponse, expectedResponse)
|
||||
AssertEqual(t, "TestOverwriteTagsWithSameKeyWhenAdded", actualResponse, expectedResponse)
|
||||
}
|
||||
|
||||
func TestFingerprintShouldBeCaptureMessage(t *testing.T) {
|
||||
@ -340,7 +320,7 @@ func TestFingerprintShouldBeCaptureMessage(t *testing.T) {
|
||||
|
||||
actualResponse := errorEvent.Fingerprint[0]
|
||||
|
||||
assertEqual(t, "TestFingerprintShouldBeCaptureMessage", actualResponse, expectedResponse)
|
||||
AssertEqual(t, "TestFingerprintShouldBeCaptureMessage", actualResponse, expectedResponse)
|
||||
}
|
||||
|
||||
func TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage(t *testing.T) {
|
||||
@ -368,7 +348,7 @@ func TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage(t *testing.T) {
|
||||
for i := range errorEvent.Fingerprint {
|
||||
expectedResponse := fingerprints[i]
|
||||
actualResponse := errorEvent.Fingerprint[i]
|
||||
assertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualResponse, expectedResponse)
|
||||
AssertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualResponse, expectedResponse)
|
||||
}
|
||||
}
|
||||
func TestCreateEventReadyForServerUsingCaptureMessage(t *testing.T) {
|
||||
@ -393,12 +373,12 @@ func TestCreateEventReadyForServerUsingCaptureMessage(t *testing.T) {
|
||||
expectedType := "message"
|
||||
actualType := errorEvent.Type
|
||||
|
||||
assertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualType, expectedType)
|
||||
AssertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualType, expectedType)
|
||||
|
||||
expectedMsg := errorMessage
|
||||
actualMsg := errorEvent.Exception.Message
|
||||
|
||||
assertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualMsg, expectedMsg)
|
||||
AssertEqual(t, "TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage", actualMsg, expectedMsg)
|
||||
}
|
||||
func TestCaptureMessageTimelineAndEventWithSameID(t *testing.T) {
|
||||
timelineOpt := TrackerOption{
|
||||
@ -424,17 +404,17 @@ func TestCaptureMessageTimelineAndEventWithSameID(t *testing.T) {
|
||||
expectedTimelineCount := 2
|
||||
actualTimelineCount := len(errorEvent.Timeline)
|
||||
|
||||
assertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", fmt.Sprint(actualTimelineCount), fmt.Sprint(expectedTimelineCount))
|
||||
AssertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", fmt.Sprint(actualTimelineCount), fmt.Sprint(expectedTimelineCount))
|
||||
|
||||
expectedEventId := errorEvent.EventId
|
||||
actualEventId := errorEvent.Timeline[0].EventId
|
||||
|
||||
assertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", actualEventId, expectedEventId)
|
||||
AssertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", actualEventId, expectedEventId)
|
||||
|
||||
expectedMsg := errorMessage
|
||||
actualMsg := errorEvent.Exception.Message
|
||||
|
||||
assertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", actualMsg, expectedMsg)
|
||||
AssertEqual(t, "TestCaptureMessageTimelineAndEventWithSameID", actualMsg, expectedMsg)
|
||||
|
||||
}
|
||||
func TestCaptureExceptionReadyForServer(t *testing.T) {
|
||||
@ -459,12 +439,12 @@ func TestCaptureExceptionReadyForServer(t *testing.T) {
|
||||
|
||||
expectedMsg := errorMessage
|
||||
actualMsg := errorEvent.Exception.Message
|
||||
assertEqual(t, "TestCaptureExceptionReadyForServer", actualMsg, expectedMsg)
|
||||
AssertEqual(t, "TestCaptureExceptionReadyForServer", actualMsg, expectedMsg)
|
||||
|
||||
expectedType := "exception"
|
||||
actualType := errorEvent.Type
|
||||
|
||||
assertEqual(t, "TestCaptureExceptionReadyForServer", actualType, expectedType)
|
||||
AssertEqual(t, "TestCaptureExceptionReadyForServer", actualType, expectedType)
|
||||
|
||||
}
|
||||
func TestCaptureExceptionAndCaptureMessageWithDifferentID(t *testing.T) {
|
||||
@ -496,24 +476,24 @@ func TestCaptureExceptionAndCaptureMessageWithDifferentID(t *testing.T) {
|
||||
expectedType := "message"
|
||||
actualType := event.Type
|
||||
|
||||
assertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualType, expectedType)
|
||||
AssertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualType, expectedType)
|
||||
|
||||
actualMessage := event.Content.(map[string]interface{})["message"].(string)
|
||||
|
||||
assertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualMessage, errorMessage)
|
||||
AssertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualMessage, errorMessage)
|
||||
|
||||
// ensure that the second event have a type exception, same error message
|
||||
expectedType = "exception"
|
||||
actualType = newEvent.Type
|
||||
|
||||
assertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualType, expectedType)
|
||||
AssertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualType, expectedType)
|
||||
|
||||
actualMessage = newEvent.Content.(map[string]interface{})["message"].(string)
|
||||
assertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualMessage, errorMessage)
|
||||
AssertEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", actualMessage, errorMessage)
|
||||
|
||||
// confim their eventId is different
|
||||
|
||||
assertNotEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", event.ID, newEvent.ID)
|
||||
AssertNotEqual(t, "TestCaptureExceptionAndCaptureMessageWithDifferentID", event.ID, newEvent.ID)
|
||||
}
|
||||
|
||||
func TestCapturedErrorWithDifferentProperties(t *testing.T) {
|
||||
@ -553,23 +533,23 @@ func TestCapturedErrorWithDifferentProperties(t *testing.T) {
|
||||
expectedType := "message"
|
||||
actualType := event.Type
|
||||
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", actualType, expectedType)
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", actualType, expectedType)
|
||||
|
||||
actualMessage := event.Content.(map[string]interface{})["message"].(string)
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", actualMessage, errorMessage)
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", actualMessage, errorMessage)
|
||||
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(event.Timeline)), "2")
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(event.Timeline)), "2")
|
||||
|
||||
// ensure that the second event have a type exception, same error message and 2 tags
|
||||
expectedType = "exception"
|
||||
actualType = newEvent.Type
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", actualType, expectedType)
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", actualType, expectedType)
|
||||
|
||||
actualMessage = newEvent.Content.(map[string]interface{})["message"].(string)
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", actualMessage, errorMessage)
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", actualMessage, errorMessage)
|
||||
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(newEvent.Timeline)), "2")
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(newEvent.Timeline)), "2")
|
||||
|
||||
assertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(newEvent.Tags)), "2") // the default and custom tag
|
||||
AssertEqual(t, "TestCapturedErrorWithDifferentProperties", fmt.Sprint(len(newEvent.Tags)), "2") // the default and custom tag
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user