From 4c80106171450ab0a4f082d38fd3e3a61f3eef1f Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Mon, 10 Jun 2019 11:21:23 +0200 Subject: [PATCH] Fix integration tests for downtimes and synthetics tests after recent changes --- integration/downtime_test.go | 8 +++++++- integration/synthetics_test.go | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/integration/downtime_test.go b/integration/downtime_test.go index f0f2a7a..f3ea2e0 100644 --- a/integration/downtime_test.go +++ b/integration/downtime_test.go @@ -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) @@ -39,6 +42,7 @@ func TestDowntimeLinkedToMonitorCreateAndDelete(t *testing.T) { } expected.SetId(downtime.GetId()) + expected.SetCreatorID(downtime.GetCreatorID()) assert.Equal(t, expected, downtime) @@ -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"}, @@ -125,6 +130,7 @@ func getTestDowntime() *datadog.Downtime { Start: datadog.Int(1577836800), End: datadog.Int(1577840400), Recurrence: r, + Type: datadog.Int(2), } } diff --git a/integration/synthetics_test.go b/integration/synthetics_test.go index ba70977..6090271 100644 --- a/integration/synthetics_test.go +++ b/integration/synthetics_test.go @@ -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) @@ -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) } @@ -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) @@ -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) } @@ -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 { @@ -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) }