Skip to content

Commit 65b402d

Browse files
authored
fix: make it possible to unassign a check/monitor from a group (#330)
1 parent 26e4c7f commit 65b402d

File tree

5 files changed

+495
-3
lines changed

5 files changed

+495
-3
lines changed

checkly/resource_check_test.go

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,3 +1503,173 @@ const apiCheck_withEmptyBasicAuth = `
15031503
}
15041504
}
15051505
`
1506+
1507+
func TestAccCheckGroupAssignment(t *testing.T) {
1508+
accTestCase(t, []resource.TestStep{
1509+
{
1510+
Config: `
1511+
resource "checkly_check_group" "test1" {
1512+
name = "test-group-assignment"
1513+
activated = true
1514+
concurrency = 1
1515+
locations = ["eu-central-1"]
1516+
}
1517+
1518+
resource "checkly_check_group" "test2" {
1519+
name = "test-group-assignment"
1520+
activated = true
1521+
concurrency = 1
1522+
locations = ["eu-central-1"]
1523+
}
1524+
1525+
resource "checkly_check" "test1" {
1526+
name = "test-group-assignment"
1527+
type = "API"
1528+
activated = true
1529+
frequency = 60
1530+
locations = ["eu-central-1"]
1531+
group_id = checkly_check_group.test1.id
1532+
request {
1533+
method = "GET"
1534+
url = "https://welcome.checklyhq.com"
1535+
}
1536+
}
1537+
1538+
resource "checkly_check" "test2" {
1539+
name = "test-group-assignment"
1540+
type = "API"
1541+
activated = true
1542+
frequency = 60
1543+
locations = ["eu-central-1"]
1544+
request {
1545+
method = "GET"
1546+
url = "https://welcome.checklyhq.com"
1547+
}
1548+
}
1549+
`,
1550+
Check: resource.ComposeTestCheckFunc(
1551+
resource.TestCheckResourceAttrPair(
1552+
"checkly_check.test1",
1553+
"group_id",
1554+
"checkly_check_group.test1",
1555+
"id",
1556+
),
1557+
resource.TestCheckResourceAttr(
1558+
"checkly_check.test2",
1559+
"group_id",
1560+
"0",
1561+
),
1562+
),
1563+
},
1564+
{
1565+
Config: `
1566+
resource "checkly_check_group" "test1" {
1567+
name = "test-group-assignment"
1568+
activated = true
1569+
concurrency = 1
1570+
locations = ["eu-central-1"]
1571+
}
1572+
1573+
resource "checkly_check_group" "test2" {
1574+
name = "test-group-assignment"
1575+
activated = true
1576+
concurrency = 1
1577+
locations = ["eu-central-1"]
1578+
}
1579+
1580+
resource "checkly_check" "test1" {
1581+
name = "test-group-assignment"
1582+
type = "API"
1583+
activated = true
1584+
frequency = 60
1585+
locations = ["eu-central-1"]
1586+
group_id = checkly_check_group.test2.id
1587+
request {
1588+
method = "GET"
1589+
url = "https://welcome.checklyhq.com"
1590+
}
1591+
}
1592+
1593+
resource "checkly_check" "test2" {
1594+
name = "test-group-assignment"
1595+
type = "API"
1596+
activated = true
1597+
frequency = 60
1598+
locations = ["eu-central-1"]
1599+
group_id = checkly_check_group.test2.id
1600+
request {
1601+
method = "GET"
1602+
url = "https://welcome.checklyhq.com"
1603+
}
1604+
}
1605+
`,
1606+
Check: resource.ComposeTestCheckFunc(
1607+
resource.TestCheckResourceAttrPair(
1608+
"checkly_check.test1",
1609+
"group_id",
1610+
"checkly_check_group.test2",
1611+
"id",
1612+
),
1613+
resource.TestCheckResourceAttrPair(
1614+
"checkly_check.test2",
1615+
"group_id",
1616+
"checkly_check_group.test2",
1617+
"id",
1618+
),
1619+
),
1620+
},
1621+
{
1622+
Config: `
1623+
resource "checkly_check_group" "test1" {
1624+
name = "test-group-assignment"
1625+
activated = true
1626+
concurrency = 1
1627+
locations = ["eu-central-1"]
1628+
}
1629+
1630+
resource "checkly_check_group" "test2" {
1631+
name = "test-group-assignment"
1632+
activated = true
1633+
concurrency = 1
1634+
locations = ["eu-central-1"]
1635+
}
1636+
1637+
resource "checkly_check" "test1" {
1638+
name = "test-group-assignment"
1639+
type = "API"
1640+
activated = true
1641+
frequency = 60
1642+
locations = ["eu-central-1"]
1643+
request {
1644+
method = "GET"
1645+
url = "https://welcome.checklyhq.com"
1646+
}
1647+
}
1648+
1649+
resource "checkly_check" "test2" {
1650+
name = "test-group-assignment"
1651+
type = "API"
1652+
activated = true
1653+
frequency = 60
1654+
locations = ["eu-central-1"]
1655+
request {
1656+
method = "GET"
1657+
url = "https://welcome.checklyhq.com"
1658+
}
1659+
}
1660+
`,
1661+
Check: resource.ComposeTestCheckFunc(
1662+
resource.TestCheckResourceAttr(
1663+
"checkly_check.test1",
1664+
"group_id",
1665+
"0",
1666+
),
1667+
resource.TestCheckResourceAttr(
1668+
"checkly_check.test2",
1669+
"group_id",
1670+
"0",
1671+
),
1672+
),
1673+
},
1674+
})
1675+
}

checkly/resource_tcp_monitor_test.go

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,3 +1004,167 @@ func TestAccTCPMonitorRetryStrategyRemoval(t *testing.T) {
10041004
},
10051005
})
10061006
}
1007+
1008+
func TestAccTCPMonitorGroupAssignment(t *testing.T) {
1009+
accTestCase(t, []resource.TestStep{
1010+
{
1011+
Config: `
1012+
resource "checkly_check_group" "test1" {
1013+
name = "test-group-assignment"
1014+
activated = true
1015+
concurrency = 1
1016+
locations = ["eu-central-1"]
1017+
}
1018+
1019+
resource "checkly_check_group" "test2" {
1020+
name = "test-group-assignment"
1021+
activated = true
1022+
concurrency = 1
1023+
locations = ["eu-central-1"]
1024+
}
1025+
1026+
resource "checkly_tcp_monitor" "test1" {
1027+
name = "test-group-assignment"
1028+
activated = true
1029+
frequency = 60
1030+
locations = ["eu-central-1"]
1031+
group_id = checkly_check_group.test1.id
1032+
request {
1033+
port = 443
1034+
hostname = "checkly.com"
1035+
}
1036+
}
1037+
1038+
resource "checkly_tcp_monitor" "test2" {
1039+
name = "test-group-assignment"
1040+
activated = true
1041+
frequency = 60
1042+
locations = ["eu-central-1"]
1043+
request {
1044+
port = 443
1045+
hostname = "checkly.com"
1046+
}
1047+
}
1048+
`,
1049+
Check: resource.ComposeTestCheckFunc(
1050+
resource.TestCheckResourceAttrPair(
1051+
"checkly_tcp_monitor.test1",
1052+
"group_id",
1053+
"checkly_check_group.test1",
1054+
"id",
1055+
),
1056+
resource.TestCheckResourceAttr(
1057+
"checkly_tcp_monitor.test2",
1058+
"group_id",
1059+
"0",
1060+
),
1061+
),
1062+
},
1063+
{
1064+
Config: `
1065+
resource "checkly_check_group" "test1" {
1066+
name = "test-group-assignment"
1067+
activated = true
1068+
concurrency = 1
1069+
locations = ["eu-central-1"]
1070+
}
1071+
1072+
resource "checkly_check_group" "test2" {
1073+
name = "test-group-assignment"
1074+
activated = true
1075+
concurrency = 1
1076+
locations = ["eu-central-1"]
1077+
}
1078+
1079+
resource "checkly_tcp_monitor" "test1" {
1080+
name = "test-group-assignment"
1081+
activated = true
1082+
frequency = 60
1083+
locations = ["eu-central-1"]
1084+
group_id = checkly_check_group.test2.id
1085+
request {
1086+
port = 443
1087+
hostname = "checkly.com"
1088+
}
1089+
}
1090+
1091+
resource "checkly_tcp_monitor" "test2" {
1092+
name = "test-group-assignment"
1093+
activated = true
1094+
frequency = 60
1095+
locations = ["eu-central-1"]
1096+
group_id = checkly_check_group.test2.id
1097+
request {
1098+
port = 443
1099+
hostname = "checkly.com"
1100+
}
1101+
}
1102+
`,
1103+
Check: resource.ComposeTestCheckFunc(
1104+
resource.TestCheckResourceAttrPair(
1105+
"checkly_tcp_monitor.test1",
1106+
"group_id",
1107+
"checkly_check_group.test2",
1108+
"id",
1109+
),
1110+
resource.TestCheckResourceAttrPair(
1111+
"checkly_tcp_monitor.test2",
1112+
"group_id",
1113+
"checkly_check_group.test2",
1114+
"id",
1115+
),
1116+
),
1117+
},
1118+
{
1119+
Config: `
1120+
resource "checkly_check_group" "test1" {
1121+
name = "test-group-assignment"
1122+
activated = true
1123+
concurrency = 1
1124+
locations = ["eu-central-1"]
1125+
}
1126+
1127+
resource "checkly_check_group" "test2" {
1128+
name = "test-group-assignment"
1129+
activated = true
1130+
concurrency = 1
1131+
locations = ["eu-central-1"]
1132+
}
1133+
1134+
resource "checkly_tcp_monitor" "test1" {
1135+
name = "test-group-assignment"
1136+
activated = true
1137+
frequency = 60
1138+
locations = ["eu-central-1"]
1139+
request {
1140+
port = 443
1141+
hostname = "checkly.com"
1142+
}
1143+
}
1144+
1145+
resource "checkly_tcp_monitor" "test2" {
1146+
name = "test-group-assignment"
1147+
activated = true
1148+
frequency = 60
1149+
locations = ["eu-central-1"]
1150+
request {
1151+
port = 443
1152+
hostname = "checkly.com"
1153+
}
1154+
}
1155+
`,
1156+
Check: resource.ComposeTestCheckFunc(
1157+
resource.TestCheckResourceAttr(
1158+
"checkly_tcp_monitor.test1",
1159+
"group_id",
1160+
"0",
1161+
),
1162+
resource.TestCheckResourceAttr(
1163+
"checkly_tcp_monitor.test2",
1164+
"group_id",
1165+
"0",
1166+
),
1167+
),
1168+
},
1169+
})
1170+
}

0 commit comments

Comments
 (0)