@@ -29,23 +29,127 @@ func TestAccDataSourceIPs_Basic(t *testing.T) {
2929 resource scaleway_lb_ip ip2 {
3030 }
3131
32- data "scaleway_lb_ips" "lbs_by_cidr_range " {
32+ data "scaleway_lb_ips" "ips_by_cidr_range " {
3333 ip_cidr_range = "0.0.0.0/0"
3434 depends_on = [scaleway_lb_ip.ip1, scaleway_lb_ip.ip2]
3535 }
36- data "scaleway_lb_ips" "lbs_by_cidr_range_other_zone " {
36+ data "scaleway_lb_ips" "ips_by_cidr_range_other_zone " {
3737 ip_cidr_range = "0.0.0.0/0"
3838 zone = "fr-par-2"
3939 depends_on = [scaleway_lb_ip.ip1, scaleway_lb_ip.ip2]
4040 }
4141 ` ,
4242 Check : resource .ComposeTestCheckFunc (
43- resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.lbs_by_cidr_range " , "ips.0.id" ),
44- resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.lbs_by_cidr_range " , "ips.0.ip_address" ),
45- resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.lbs_by_cidr_range " , "ips.1.id" ),
46- resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.lbs_by_cidr_range " , "ips.1.ip_address" ),
43+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_cidr_range " , "ips.0.id" ),
44+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_cidr_range " , "ips.0.ip_address" ),
45+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_cidr_range " , "ips.1.id" ),
46+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_cidr_range " , "ips.1.ip_address" ),
4747
48- resource .TestCheckNoResourceAttr ("data.scaleway_lb_ips.lbs_by_cidr_range_other_zone" , "ips.0.id" ),
48+ resource .TestCheckNoResourceAttr ("data.scaleway_lb_ips.ips_by_cidr_range_other_zone" , "ips.0.id" ),
49+ ),
50+ },
51+ },
52+ })
53+ }
54+
55+ func TestAccDataSourceIPs_WithType (t * testing.T ) {
56+ tt := acctest .NewTestTools (t )
57+ defer tt .Cleanup ()
58+ resource .ParallelTest (t , resource.TestCase {
59+ PreCheck : func () { acctest .PreCheck (t ) },
60+ ProviderFactories : tt .ProviderFactories ,
61+ CheckDestroy : lbchecks .IsIPDestroyed (tt ),
62+ Steps : []resource.TestStep {
63+ {
64+ Config : `
65+ resource scaleway_lb_ip ip1 {
66+ }
67+ ` ,
68+ },
69+ {
70+ Config : `
71+ resource scaleway_lb_ip ip1 {
72+ }
73+ resource scaleway_lb_ip ip2 {
74+ is_ipv6 = true
75+ }
76+ ` ,
77+ },
78+ {
79+ Config : `
80+ resource scaleway_lb_ip ip1 {
81+ }
82+ resource scaleway_lb_ip ip2 {
83+ is_ipv6 = true
84+ }
85+ resource scaleway_lb_ip ip3 {
86+ }
87+
88+ data "scaleway_lb_ips" "ips_by_type" {
89+ ip_type = "ipv4"
90+ depends_on = [scaleway_lb_ip.ip1, scaleway_lb_ip.ip2, scaleway_lb_ip.ip3]
91+ }
92+ ` ,
93+ Check : resource .ComposeTestCheckFunc (
94+ resource .TestCheckResourceAttr ("data.scaleway_lb_ips.ips_by_type" , "ips.#" , "2" ),
95+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_type" , "ips.0.id" ),
96+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_type" , "ips.0.ip_address" ),
97+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_type" , "ips.1.id" ),
98+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_type" , "ips.1.ip_address" ),
99+ ),
100+ },
101+ },
102+ })
103+ }
104+
105+ func TestAccDataSourceIPs_WithTags (t * testing.T ) {
106+ tt := acctest .NewTestTools (t )
107+ defer tt .Cleanup ()
108+ resource .ParallelTest (t , resource.TestCase {
109+ PreCheck : func () { acctest .PreCheck (t ) },
110+ ProviderFactories : tt .ProviderFactories ,
111+ CheckDestroy : lbchecks .IsIPDestroyed (tt ),
112+ Steps : []resource.TestStep {
113+ {
114+ Config : `
115+ resource scaleway_lb_ip ip1 {
116+ tags = [ "ipv4", "ip" ]
117+ }
118+ ` ,
119+ },
120+ {
121+ Config : `
122+ resource scaleway_lb_ip ip1 {
123+ tags = [ "ipv4", "ip" ]
124+ }
125+ resource scaleway_lb_ip ip2 {
126+ tags = [ "ipv4", "ip" ]
127+ }
128+ ` ,
129+ },
130+ {
131+ Config : `
132+ resource scaleway_lb_ip ip1 {
133+ tags = [ "ipv4", "ip" ]
134+ }
135+ resource scaleway_lb_ip ip2 {
136+ tags = [ "ipv4", "ip" ]
137+ }
138+ resource scaleway_lb_ip ip3 {
139+ tags = [ "other", "tags" ]
140+ }
141+
142+ data "scaleway_lb_ips" "ips_by_tags" {
143+ tags = [ "ipv4", "ip" ]
144+ depends_on = [scaleway_lb_ip.ip1, scaleway_lb_ip.ip2, scaleway_lb_ip.ip3]
145+ }
146+ ` ,
147+ Check : resource .ComposeTestCheckFunc (
148+ resource .TestCheckResourceAttr ("data.scaleway_lb_ips.ips_by_tags" , "ips.#" , "2" ),
149+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_tags" , "ips.0.id" ),
150+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_tags" , "ips.0.ip_address" ),
151+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_tags" , "ips.1.id" ),
152+ resource .TestCheckResourceAttrSet ("data.scaleway_lb_ips.ips_by_tags" , "ips.1.ip_address" ),
49153 ),
50154 },
51155 },
0 commit comments