@@ -3,9 +3,10 @@ package synthetics
33import (
44 "context"
55 "encoding/json"
6- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
76 "testing"
87
8+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
9+
910 "github.com/disaster37/go-kibana-rest/v8/kbapi"
1011 "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
1112 "github.com/hashicorp/terraform-plugin-framework/attr"
@@ -49,6 +50,7 @@ func TestToModelV0(t *testing.T) {
4950 ID : types .StringValue ("/" ),
5051 Name : types .StringValue ("" ),
5152 SpaceID : types .StringValue ("" ),
53+ Namespace : types .StringValue ("" ),
5254 Schedule : types .Int64Value (0 ),
5355 APMServiceName : types .StringValue ("" ),
5456 TimeoutSeconds : types .Int64Value (0 ),
@@ -83,6 +85,7 @@ func TestToModelV0(t *testing.T) {
8385 ID : types .StringValue ("/" ),
8486 Name : types .StringValue ("" ),
8587 SpaceID : types .StringValue ("" ),
88+ Namespace : types .StringValue ("" ),
8689 Schedule : types .Int64Value (0 ),
8790 APMServiceName : types .StringValue ("" ),
8891 TimeoutSeconds : types .Int64Value (0 ),
@@ -111,6 +114,7 @@ func TestToModelV0(t *testing.T) {
111114 ID : types .StringValue ("/" ),
112115 Name : types .StringValue ("" ),
113116 SpaceID : types .StringValue ("" ),
117+ Namespace : types .StringValue ("" ),
114118 Schedule : types .Int64Value (0 ),
115119 APMServiceName : types .StringValue ("" ),
116120 TimeoutSeconds : types .Int64Value (0 ),
@@ -130,6 +134,7 @@ func TestToModelV0(t *testing.T) {
130134 ID : types .StringValue ("/" ),
131135 Name : types .StringValue ("" ),
132136 SpaceID : types .StringValue ("" ),
137+ Namespace : types .StringValue ("" ),
133138 Schedule : types .Int64Value (0 ),
134139 APMServiceName : types .StringValue ("" ),
135140 TimeoutSeconds : types .Int64Value (0 ),
@@ -191,6 +196,7 @@ func TestToModelV0(t *testing.T) {
191196 ID : types .StringValue ("default/test-id-http" ),
192197 Name : types .StringValue ("test-name-http" ),
193198 SpaceID : types .StringValue ("default" ),
199+ Namespace : types .StringValue ("default" ),
194200 Schedule : types .Int64Value (5 ),
195201 Locations : []types.String {types .StringValue ("us_east" )},
196202 PrivateLocations : []types.String {types .StringValue ("test private location" )},
@@ -229,7 +235,7 @@ func TestToModelV0(t *testing.T) {
229235 input : kbapi.SyntheticsMonitor {
230236 Id : "test-id-tcp" ,
231237 Name : "test-name-tcp" ,
232- Namespace : "default" ,
238+ Namespace : "default-2 " ,
233239 Enabled : tBool ,
234240 Alert : & kbapi.MonitorAlertConfig {Status : & kbapi.SyntheticsStatusConfig {Enabled : tBool }},
235241 Schedule : & kbapi.MonitorScheduleConfig {Number : "5" , Unit : "m" },
@@ -261,6 +267,7 @@ func TestToModelV0(t *testing.T) {
261267 ID : types .StringValue ("default/test-id-tcp" ),
262268 Name : types .StringValue ("test-name-tcp" ),
263269 SpaceID : types .StringValue ("default" ),
270+ Namespace : types .StringValue ("default-2" ),
264271 Schedule : types .Int64Value (5 ),
265272 Locations : nil ,
266273 PrivateLocations : []types.String {types .StringValue ("test private location" )},
@@ -320,6 +327,7 @@ func TestToModelV0(t *testing.T) {
320327 ID : types .StringValue ("default/test-id-icmp" ),
321328 Name : types .StringValue ("test-name-icmp" ),
322329 SpaceID : types .StringValue ("default" ),
330+ Namespace : types .StringValue ("default" ),
323331 Schedule : types .Int64Value (5 ),
324332 Locations : nil ,
325333 PrivateLocations : []types.String {types .StringValue ("test private location" )},
@@ -375,6 +383,7 @@ func TestToModelV0(t *testing.T) {
375383 ID : types .StringValue ("default/test-id-browser" ),
376384 Name : types .StringValue ("test-name-browser" ),
377385 SpaceID : types .StringValue ("default" ),
386+ Namespace : types .StringValue ("default" ),
378387 Schedule : types .Int64Value (5 ),
379388 Locations : nil ,
380389 PrivateLocations : []types.String {types .StringValue ("test private location" )},
@@ -398,7 +407,7 @@ func TestToModelV0(t *testing.T) {
398407 for _ , tt := range testcases {
399408 t .Run (tt .name , func (t * testing.T ) {
400409 ctx := context .Background ()
401- model , diag := tt .expected .toModelV0 (ctx , & tt .input )
410+ model , diag := tt .expected .toModelV0 (ctx , & tt .input , tt . expected . SpaceID . ValueString () )
402411 assert .False (t , diag .HasError ())
403412 assert .Equal (t , & tt .expected , model )
404413 })
@@ -457,6 +466,7 @@ func TestToKibanaAPIRequest(t *testing.T) {
457466 ID : types .StringValue ("test-id-http" ),
458467 Name : types .StringValue ("test-name-http" ),
459468 SpaceID : types .StringValue ("default" ),
469+ Namespace : types .StringValue ("default-3" ),
460470 Schedule : types .Int64Value (5 ),
461471 Locations : []types.String {types .StringValue ("us_east" )},
462472 PrivateLocations : []types.String {types .StringValue ("test private location" )},
@@ -500,7 +510,7 @@ func TestToKibanaAPIRequest(t *testing.T) {
500510 Tags : []string {"tag1" , "tag2" },
501511 Alert : & kbapi.MonitorAlertConfig {Status : & kbapi.SyntheticsStatusConfig {Enabled : tBool }, Tls : & kbapi.SyntheticsStatusConfig {Enabled : fBool }},
502512 APMServiceName : "test-service-http" ,
503- Namespace : "default" ,
513+ Namespace : "default-3 " ,
504514 TimeoutSeconds : 30 ,
505515 Params : kbapi.JsonObject {"param1" : "value1" },
506516 },
@@ -533,6 +543,7 @@ func TestToKibanaAPIRequest(t *testing.T) {
533543 ID : types .StringValue ("test-id-tcp" ),
534544 Name : types .StringValue ("test-name-tcp" ),
535545 SpaceID : types .StringValue ("default" ),
546+ Namespace : types .StringValue ("default" ),
536547 Schedule : types .Int64Value (5 ),
537548 Locations : []types.String {types .StringValue ("us_east" )},
538549 PrivateLocations : nil ,
@@ -597,6 +608,7 @@ func TestToKibanaAPIRequest(t *testing.T) {
597608 ID : types .StringValue ("test-id-icmp" ),
598609 Name : types .StringValue ("test-name-icmp" ),
599610 SpaceID : types .StringValue ("default" ),
611+ Namespace : types .StringValue ("default" ),
600612 Schedule : types .Int64Value (5 ),
601613 Locations : []types.String {types .StringValue ("us_east" )},
602614 PrivateLocations : nil ,
@@ -637,6 +649,7 @@ func TestToKibanaAPIRequest(t *testing.T) {
637649 ID : types .StringValue ("test-id-browser" ),
638650 Name : types .StringValue ("test-name-browser" ),
639651 SpaceID : types .StringValue ("default" ),
652+ Namespace : types .StringValue ("default" ),
640653 Schedule : types .Int64Value (5 ),
641654 Locations : []types.String {types .StringValue ("us_east" )},
642655 PrivateLocations : nil ,
@@ -722,6 +735,7 @@ func TestToModelV0MergeAttributes(t *testing.T) {
722735 ID : types .StringValue ("/" ),
723736 Name : types .StringValue ("" ),
724737 SpaceID : types .StringValue ("" ),
738+ Namespace : types .StringValue ("" ),
725739 Schedule : types .Int64Value (0 ),
726740 APMServiceName : types .StringValue ("" ),
727741 TimeoutSeconds : types .Int64Value (0 ),
@@ -767,6 +781,7 @@ func TestToModelV0MergeAttributes(t *testing.T) {
767781 ID : types .StringValue ("/" ),
768782 Name : types .StringValue ("" ),
769783 SpaceID : types .StringValue ("" ),
784+ Namespace : types .StringValue ("" ),
770785 Schedule : types .Int64Value (0 ),
771786 APMServiceName : types .StringValue ("" ),
772787 TimeoutSeconds : types .Int64Value (0 ),
@@ -801,6 +816,7 @@ func TestToModelV0MergeAttributes(t *testing.T) {
801816 ID : types .StringValue ("/" ),
802817 Name : types .StringValue ("" ),
803818 SpaceID : types .StringValue ("" ),
819+ Namespace : types .StringValue ("" ),
804820 Schedule : types .Int64Value (0 ),
805821 APMServiceName : types .StringValue ("" ),
806822 TimeoutSeconds : types .Int64Value (0 ),
@@ -816,7 +832,7 @@ func TestToModelV0MergeAttributes(t *testing.T) {
816832 for _ , tt := range testcases {
817833 t .Run (tt .name , func (t * testing.T ) {
818834 ctx := context .Background ()
819- actual , diag := tt .state .toModelV0 (ctx , & tt .input )
835+ actual , diag := tt .state .toModelV0 (ctx , & tt .input , tt . state . SpaceID . ValueString () )
820836 assert .False (t , diag .HasError ())
821837 assert .NotNil (t , actual )
822838 assert .Equal (t , & tt .expected , actual )
0 commit comments