From 7e28a7d57d4654f21270ac5041f8baf378e4a7ff Mon Sep 17 00:00:00 2001 From: Zadat Olayinka Date: Thu, 5 Aug 2021 10:16:50 +0100 Subject: [PATCH] test updatd --- go-sdk/tracker_test.go | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/go-sdk/tracker_test.go b/go-sdk/tracker_test.go index 228b8331df..ef8d7b3f73 100644 --- a/go-sdk/tracker_test.go +++ b/go-sdk/tracker_test.go @@ -388,3 +388,83 @@ func TestFingerprintShouldBeCustomValuesSetAheadCaptureMessage(t *testing.T) { } } } +func TestCreateEventReadyForServerUsingCaptureMessage(t *testing.T) { + timelineOpt := TrackerOption{ + MaxTimeline: 2, + } + option := FyipeTrackerOption{ + ErrorTrackerId: errorTracker["_id"].(string), + ErrorTrackerKey: errorTracker["key"].(string), + ApiUrl: apiUrl, + Options: timelineOpt, + } + + InitTracker(option) + + errorMessage := "Uncaught Exception" + + CaptureMessage(errorMessage) + + errorEvent := GetErrorEvent() + + expectedType := "message" + actualType := errorEvent.Type + if actualType != expectedType { + t.Errorf("TestCreateEventReadyForServerUsingCaptureMessage failed expected %v, got %v", expectedType, actualType) + } else { + t.Logf("TestCreateEventReadyForServerUsingCaptureMessage success expected %v, got %v", expectedType, actualType) + } + + expectedMsg := errorMessage + actualMsg := errorEvent.Exception.Message + if actualMsg != expectedMsg { + t.Errorf("TestCreateEventReadyForServerUsingCaptureMessage failed expected %v, got %v", expectedMsg, actualMsg) + } else { + t.Logf("TestCreateEventReadyForServerUsingCaptureMessage success expected %v, got %v", expectedMsg, actualMsg) + } +} +func TestCaptureMessageTimelineAndEventWithSameID(t *testing.T) { + timelineOpt := TrackerOption{ + MaxTimeline: 2, + } + option := FyipeTrackerOption{ + ErrorTrackerId: errorTracker["_id"].(string), + ErrorTrackerKey: errorTracker["key"].(string), + ApiUrl: apiUrl, + Options: timelineOpt, + } + + InitTracker(option) + + AddToTimeline(customTimeline) + + errorMessage := "Uncaught Exception" + + CaptureMessage(errorMessage) + + errorEvent := GetErrorEvent() + + expectedTimelineCount := 2 + actualTimelineCount := len(errorEvent.Timeline) + if actualTimelineCount != expectedTimelineCount { + t.Errorf("TestCaptureMessageTimelineAndEventWithSameID failed expected %v, got %v", expectedTimelineCount, actualTimelineCount) + } else { + t.Logf("TestCaptureMessageTimelineAndEventWithSameID success expected %v, got %v", expectedTimelineCount, actualTimelineCount) + } + + expectedEventId := errorEvent.EventId + actualEventId := errorEvent.Timeline[0].EventId + if actualEventId != expectedEventId { + t.Errorf("TestCaptureMessageTimelineAndEventWithSameID failed expected %v, got %v", expectedEventId, actualEventId) + } else { + t.Logf("TestCaptureMessageTimelineAndEventWithSameID success expected %v, got %v", expectedEventId, actualEventId) + } + + expectedMsg := errorMessage + actualMsg := errorEvent.Exception.Message + if actualMsg != expectedMsg { + t.Errorf("TestCaptureMessageTimelineAndEventWithSameID failed expected %v, got %v", expectedMsg, actualMsg) + } else { + t.Logf("TestCaptureMessageTimelineAndEventWithSameID success expected %v, got %v", expectedMsg, actualMsg) + } +}