Skip to content

Commit ec921fa

Browse files
committed
chore: add test
1 parent 1105df7 commit ec921fa

File tree

3 files changed

+235
-220
lines changed

3 files changed

+235
-220
lines changed

internal/services/domain/domains_registration.go

Lines changed: 144 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -275,124 +275,132 @@ func ResourceDomainsRegistration() *schema.Resource {
275275
Description: "List of Scaleway resources linked to the domain.",
276276
},
277277

278-
"tld": {
279-
Type: schema.TypeList,
280-
Computed: true,
281-
Description: "Details about the TLD (Top-Level Domain).",
282-
Elem: &schema.Resource{
283-
Schema: map[string]*schema.Schema{
284-
"name": {
285-
Type: schema.TypeString,
286-
Computed: true,
287-
Description: "Name of the TLD.",
288-
},
289-
"dnssec_support": {
290-
Type: schema.TypeBool,
291-
Computed: true,
292-
Description: "Indicates whether dnssec is supported for this TLD.",
293-
},
294-
"duration_in_years_min": {
295-
Type: schema.TypeInt,
296-
Computed: true,
297-
Description: "Minimum duration (in years) for which this TLD can be registered.",
298-
},
299-
"duration_in_years_max": {
300-
Type: schema.TypeInt,
301-
Computed: true,
302-
Description: "Maximum duration (in years) for which this TLD can be registered.",
303-
},
304-
"idn_support": {
305-
Type: schema.TypeBool,
306-
Computed: true,
307-
Description: "Indicates whether this TLD supports IDN (Internationalized Domain Names).",
308-
},
309-
"offers": {
310-
Type: schema.TypeList,
311-
Computed: true,
312-
Description: "Available offers for the TLD.",
313-
Elem: &schema.Resource{
314-
Schema: map[string]*schema.Schema{
315-
"action": {
316-
Type: schema.TypeString,
317-
Computed: true,
318-
Description: "Type of the offer action (e.g., create, transfer).",
319-
},
320-
"operation_path": {
321-
Type: schema.TypeString,
322-
Computed: true,
323-
Description: "Path of the operation associated with the offer.",
324-
},
325-
"price": {
326-
Type: schema.TypeMap,
327-
Computed: true,
328-
Elem: &schema.Schema{
329-
Type: schema.TypeString,
330-
},
331-
Description: "Pricing information for the TLD offer.",
332-
},
333-
},
334-
},
335-
},
336-
},
337-
},
338-
},
339-
"dns_zones": {
340-
Type: schema.TypeList,
341-
Computed: true,
342-
Description: "List of DNS zones with detailed information.",
343-
Elem: &schema.Resource{
344-
Schema: map[string]*schema.Schema{
345-
"domain": {
346-
Type: schema.TypeString,
347-
Computed: true,
348-
Description: "The domain name of the DNS zone.",
349-
},
350-
"subdomain": {
351-
Type: schema.TypeString,
352-
Computed: true,
353-
Description: "The subdomain of the DNS zone.",
354-
},
355-
"ns": {
356-
Type: schema.TypeList,
357-
Computed: true,
358-
Elem: &schema.Schema{Type: schema.TypeString},
359-
Description: "List of name servers (NS) of the DNS zone.",
360-
},
361-
"ns_default": {
362-
Type: schema.TypeList,
363-
Computed: true,
364-
Elem: &schema.Schema{Type: schema.TypeString},
365-
Description: "List of default name servers of the DNS zone.",
366-
},
367-
"ns_master": {
368-
Type: schema.TypeList,
369-
Computed: true,
370-
Elem: &schema.Schema{Type: schema.TypeString},
371-
Description: "List of master name servers of the DNS zone.",
372-
},
373-
"status": {
374-
Type: schema.TypeString,
375-
Computed: true,
376-
Description: "The status of the DNS zone.",
377-
},
378-
"message": {
379-
Type: schema.TypeString,
380-
Computed: true,
381-
Description: "Additional message for the DNS zone.",
382-
},
383-
"updated_at": {
384-
Type: schema.TypeString,
385-
Computed: true,
386-
Description: "The last updated timestamp of the DNS zone.",
387-
},
388-
"project_id": {
389-
Type: schema.TypeString,
390-
Computed: true,
391-
Description: "The project ID associated with the DNS zone.",
392-
},
393-
},
394-
},
395-
},
278+
//"tld": {
279+
// Type: schema.TypeList,
280+
// Computed: true,
281+
// Description: "Details about the TLD (Top-Level Domain).",
282+
// Elem: &schema.Resource{
283+
// Schema: map[string]*schema.Schema{
284+
// "name": {
285+
// Type: schema.TypeString,
286+
// Computed: true,
287+
// Description: "Name of the TLD.",
288+
// },
289+
// "dnssec_support": {
290+
// Type: schema.TypeBool,
291+
// Computed: true,
292+
// Description: "Indicates whether dnssec is supported for this TLD.",
293+
// },
294+
// "duration_in_years_min": {
295+
// Type: schema.TypeInt,
296+
// Computed: true,
297+
// Description: "Minimum duration (in years) for which this TLD can be registered.",
298+
// },
299+
// "duration_in_years_max": {
300+
// Type: schema.TypeInt,
301+
// Computed: true,
302+
// Description: "Maximum duration (in years) for which this TLD can be registered.",
303+
// },
304+
// "idn_support": {
305+
// Type: schema.TypeBool,
306+
// Computed: true,
307+
// Description: "Indicates whether this TLD supports IDN (Internationalized Domain Names).",
308+
// },
309+
// "offers": {
310+
// Type: schema.TypeList,
311+
// Computed: true,
312+
// Description: "Available offers for the TLD.",
313+
// Elem: &schema.Resource{
314+
// Schema: map[string]*schema.Schema{
315+
// "action": {
316+
// Type: schema.TypeString,
317+
// Computed: true,
318+
// Description: "Type of the offer action (e.g., create, transfer).",
319+
// },
320+
// "operation_path": {
321+
// Type: schema.TypeString,
322+
// Computed: true,
323+
// Description: "Path of the operation associated with the offer.",
324+
// },
325+
// "price": {
326+
// Type: schema.TypeMap,
327+
// Computed: true,
328+
// Elem: &schema.Schema{
329+
// Type: schema.TypeString,
330+
// },
331+
// Description: "Pricing information for the TLD offer.",
332+
// },
333+
// },
334+
// },
335+
// },
336+
// "specifications": {
337+
// Type: schema.TypeMap,
338+
// Computed: true,
339+
// Description: "Additional TLD specifications such as grace periods.",
340+
// Elem: &schema.Schema{
341+
// Type: schema.TypeString,
342+
// },
343+
// },
344+
// },
345+
// },
346+
//},
347+
//"dns_zones": {
348+
// Type: schema.TypeList,
349+
// Computed: true,
350+
// Description: "List of DNS zones with detailed information.",
351+
// Elem: &schema.Resource{
352+
// Schema: map[string]*schema.Schema{
353+
// "domain": {
354+
// Type: schema.TypeString,
355+
// Computed: true,
356+
// Description: "The domain name of the DNS zone.",
357+
// },
358+
// "subdomain": {
359+
// Type: schema.TypeString,
360+
// Computed: true,
361+
// Description: "The subdomain of the DNS zone.",
362+
// },
363+
// "ns": {
364+
// Type: schema.TypeList,
365+
// Computed: true,
366+
// Elem: &schema.Schema{Type: schema.TypeString},
367+
// Description: "List of name servers (NS) of the DNS zone.",
368+
// },
369+
// "ns_default": {
370+
// Type: schema.TypeList,
371+
// Computed: true,
372+
// Elem: &schema.Schema{Type: schema.TypeString},
373+
// Description: "List of default name servers of the DNS zone.",
374+
// },
375+
// "ns_master": {
376+
// Type: schema.TypeList,
377+
// Computed: true,
378+
// Elem: &schema.Schema{Type: schema.TypeString},
379+
// Description: "List of master name servers of the DNS zone.",
380+
// },
381+
// "status": {
382+
// Type: schema.TypeString,
383+
// Computed: true,
384+
// Description: "The status of the DNS zone.",
385+
// },
386+
// "message": {
387+
// Type: schema.TypeString,
388+
// Computed: true,
389+
// Description: "Additional message for the DNS zone.",
390+
// },
391+
// "updated_at": {
392+
// Type: schema.TypeString,
393+
// Computed: true,
394+
// Description: "The last updated timestamp of the DNS zone.",
395+
// },
396+
// "project_id": {
397+
// Type: schema.TypeString,
398+
// Computed: true,
399+
// Description: "The project ID associated with the DNS zone.",
400+
// },
401+
// },
402+
// },
403+
//},
396404
},
397405
},
398406
},
@@ -679,7 +687,7 @@ func resourceDomainsRegistrationsRead(ctx context.Context, d *schema.ResourceDat
679687

680688
// Prépare la map de retour pour le champ `domain_info`
681689
// Clé = le nom de domaine
682-
// Valeur = un tableau (TypeList) contenant un objet (map[string]interface{}) avec toutes les propriétés
690+
// Valeur = une liste (TypeList) contenant un seul objet (map[string]interface{})
683691
domainInfoMap := make(map[string]interface{})
684692

685693
for _, domainName := range domainNames {
@@ -742,22 +750,23 @@ func resourceDomainsRegistrationsRead(ctx context.Context, d *schema.ResourceDat
742750
domainInfoObject["linked_products"] = []string{}
743751
}
744752

745-
// TLD
746-
if domainResp.Tld != nil {
747-
domainInfoObject["tld"] = flattenTLD(domainResp.Tld)
748-
} else {
749-
domainInfoObject["tld"] = []map[string]interface{}{}
750-
}
751-
752-
// DNS Zones
753-
if len(domainResp.DNSZones) > 0 {
754-
domainInfoObject["dns_zones"] = flattenDNSZones(domainResp.DNSZones)
755-
} else {
756-
domainInfoObject["dns_zones"] = []map[string]interface{}{}
757-
}
758-
759-
// On range cet objet dans un slice, car `domain_info`->Elem est un TypeList
760-
domainInfoMap[domainName] = []map[string]interface{}{
753+
//// TLD
754+
//if domainResp.Tld != nil {
755+
// domainInfoObject["tld"] = flattenTLD(domainResp.Tld)
756+
//} else {
757+
// domainInfoObject["tld"] = []map[string]interface{}{}
758+
//}
759+
760+
//// DNS Zones
761+
//if len(domainResp.DNSZones) > 0 {
762+
// domainInfoObject["dns_zones"] = flattenDNSZones(domainResp.DNSZones)
763+
//} else {
764+
// domainInfoObject["dns_zones"] = []map[string]interface{}{}
765+
//}
766+
767+
// Au lieu d'un slice de type []map[string]interface{},
768+
// on crée un slice de type []interface{} (et on y place l'objet)
769+
domainInfoMap[domainName] = []interface{}{
761770
domainInfoObject,
762771
}
763772
}

internal/services/domain/domains_registration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestAccDomainRegistration_SingleDomainWithUpdate(t *testing.T) {
1616
tt := acctest.NewTestTools(t)
1717
defer tt.Cleanup()
1818

19-
singleDomain := "test-single-updates11" + ".com" // à adapter
19+
singleDomain := "test-single-updates23" + ".com" // à adapter
2020

2121
resource.ParallelTest(t, resource.TestCase{
2222
PreCheck: func() { acctest.PreCheck(t) },

0 commit comments

Comments
 (0)