Skip to content

Commit 727afb2

Browse files
authored
Merge pull request #499 from ovh/497-bug-ovh_me_installation_template-datasource-dont-handle-properly-non-existing-template
add acceptance test for a template name not found + fix the #497 issue
2 parents 82ebaa6 + 68dcac9 commit 727afb2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: ovh/data_me_installation_template.go

+3
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ func dataSourceMeInstallationTemplateRead(d *schema.ResourceData, meta interface
254254
if err != nil {
255255
return err
256256
}
257+
if template == nil {
258+
return fmt.Errorf("Your query returned no results. Please change your search criteria")
259+
}
257260

258261
// set attributes
259262
for k, v := range template.ToMap() {

Diff for: ovh/data_me_installation_template_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ovh
22

33
import (
44
"fmt"
5+
"regexp"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
@@ -45,10 +46,19 @@ func TestAccMeInstallationTemplateDataSource_basic(t *testing.T) {
4546
),
4647
),
4748
},
49+
{
50+
Config: testAccMeInstallationTemplateDatasourceConfig_404,
51+
ExpectError: regexp.MustCompile("Your query returned no results. Please change your search criteria"),
52+
},
4853
},
4954
})
5055
}
5156

57+
const testAccMeInstallationTemplateDatasourceConfig_404 = `
58+
data "ovh_me_installation_template" "template" {
59+
template_name = "42"
60+
}
61+
`
5262
const testAccMeInstallationTemplateDatasourceConfig_Basic = `
5363
resource "ovh_me_installation_template" "template" {
5464
base_template_name = "centos7_64"

0 commit comments

Comments
 (0)