Skip to content

Commit

Permalink
Merge pull request #246 from bkabrda/fix-integration-tests
Browse files Browse the repository at this point in the history
Fix integration tests for downtimes and synthetics tests after recent changes
  • Loading branch information
Slavek Kabrda authored Jun 10, 2019
2 parents 089b178 + 4c80106 commit 9112038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion integration/downtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ func TestDowntimeCreateAndDelete(t *testing.T) {
actual := createTestDowntime(t)
defer cleanUpDowntime(t, *actual.Id)

// Set ID of our original struct to zero so we can easily compare the results
// Set ID of our original struct to ID of the returned struct so we can easily compare the results
expected.SetId(actual.GetId())
// Set creator ID for the same reason (there's no easy way to get ID of current user ATM,
// but if there was, we could do this dynamically)
expected.SetCreatorID(actual.GetCreatorID())

assert.Equal(t, expected, actual)

Expand All @@ -39,6 +42,7 @@ func TestDowntimeLinkedToMonitorCreateAndDelete(t *testing.T) {
}

expected.SetId(downtime.GetId())
expected.SetCreatorID(downtime.GetCreatorID())

assert.Equal(t, expected, downtime)

Expand Down Expand Up @@ -116,6 +120,7 @@ func getTestDowntime() *datadog.Downtime {

return &datadog.Downtime{
Active: datadog.Bool(false),
CreatorID: datadog.Int(123),
Disabled: datadog.Bool(false),
Message: datadog.String("Test downtime message"),
MonitorTags: []string{"some:tag"},
Expand All @@ -125,6 +130,7 @@ func getTestDowntime() *datadog.Downtime {
Start: datadog.Int(1577836800),
End: datadog.Int(1577840400),
Recurrence: r,
Type: datadog.Int(2),
}
}

Expand Down
6 changes: 6 additions & 0 deletions integration/synthetics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestSyntheticsCreateAndDelete(t *testing.T) {
// Set Creator to the original struct as we can't predict details of the creator
expected.SetCreatedAt(actual.GetCreatedAt())
expected.SetModifiedAt(actual.GetModifiedAt())
expected.SetMonitorId(actual.GetMonitorId())

assert.Equal(t, expected, actual)

Expand All @@ -28,6 +29,7 @@ func TestSyntheticsCreateAndDelete(t *testing.T) {
expected.SetStatus(actual.GetStatus())
expected.SetCreatedBy(actual.GetCreatedBy())
expected.SetModifiedBy(actual.GetModifiedBy())
expected.SetMonitorId(actual.GetMonitorId())
assert.Equal(t, expected, actual)
}

Expand All @@ -42,6 +44,7 @@ func TestSyntheticsUpdate(t *testing.T) {
syntheticsTest.PublicId = nil
syntheticsTest.CreatedAt = nil
syntheticsTest.ModifiedAt = nil
syntheticsTest.MonitorId = nil
actual, err := client.UpdateSyntheticsTest(publicId, syntheticsTest)
if err != nil {
t.Fatalf("Updating a synthetics test failed when it shouldn't: %s", err)
Expand All @@ -50,6 +53,7 @@ func TestSyntheticsUpdate(t *testing.T) {
syntheticsTest.SetPublicId(publicId)
syntheticsTest.SetCreatedAt(createdAt)
syntheticsTest.SetModifiedAt(actual.GetModifiedAt())
syntheticsTest.SetMonitorId(actual.GetMonitorId())
assert.Equal(t, syntheticsTest, actual)

}
Expand All @@ -64,6 +68,7 @@ func TestSyntheticsUpdateRemovingTags(t *testing.T) {
syntheticsTest.PublicId = nil
syntheticsTest.CreatedAt = nil
syntheticsTest.ModifiedAt = nil
syntheticsTest.MonitorId = nil
syntheticsTest.Tags = []string{}
actual, err := client.UpdateSyntheticsTest(publicId, syntheticsTest)
if err != nil {
Expand All @@ -73,6 +78,7 @@ func TestSyntheticsUpdateRemovingTags(t *testing.T) {
syntheticsTest.SetPublicId(publicId)
syntheticsTest.SetCreatedAt(createdAt)
syntheticsTest.SetModifiedAt(actual.GetModifiedAt())
syntheticsTest.SetMonitorId(actual.GetMonitorId())
assert.Equal(t, syntheticsTest, actual)

}
Expand Down

0 comments on commit 9112038

Please sign in to comment.