-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
cbe48c1
commit 4f1a7d1
Showing
7 changed files
with
1,965 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
`google_dialogflow_cx_flow` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
149 changes: 149 additions & 0 deletions
149
google-beta/resource_dialogflow_cx_flow_generated_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAccDialogflowCXFlow_dialogflowcxFlowFullExample(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckDialogflowCXFlowDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDialogflowCXFlow_dialogflowcxFlowFullExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_dialogflow_cx_flow.basic_flow", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"parent"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDialogflowCXFlow_dialogflowcxFlowFullExample(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_dialogflow_cx_agent" "agent" { | ||
display_name = "tf-test-dialogflowcx-agent%{random_suffix}" | ||
location = "global" | ||
default_language_code = "en" | ||
supported_language_codes = ["fr","de","es"] | ||
time_zone = "America/New_York" | ||
description = "Example description." | ||
avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png" | ||
enable_stackdriver_logging = true | ||
enable_spell_correction = true | ||
speech_to_text_settings { | ||
enable_speech_adaptation = true | ||
} | ||
} | ||
resource "google_dialogflow_cx_flow" "basic_flow" { | ||
parent = google_dialogflow_cx_agent.agent.id | ||
display_name = "MyFlow" | ||
description = "Test Flow" | ||
nlu_settings { | ||
classification_threshold = 0.3 | ||
model_type = "MODEL_TYPE_STANDARD" | ||
} | ||
event_handlers { | ||
event = "custom-event" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["I didn't get that. Can you say it again?"] | ||
} | ||
} | ||
} | ||
} | ||
event_handlers { | ||
event = "sys.no-match-default" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["Sorry, could you say that again?"] | ||
} | ||
} | ||
} | ||
} | ||
event_handlers { | ||
event = "sys.no-input-default" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["One more time?"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccCheckDialogflowCXFlowDestroyProducer(t *testing.T) func(s *terraform.State) error { | ||
return func(s *terraform.State) error { | ||
for name, rs := range s.RootModule().Resources { | ||
if rs.Type != "google_dialogflow_cx_flow" { | ||
continue | ||
} | ||
if strings.HasPrefix(name, "data.") { | ||
continue | ||
} | ||
|
||
config := googleProviderConfig(t) | ||
|
||
url, err := replaceVarsForTest(config, rs, "{{DialogflowCXBasePath}}{{parent}}/flows/{{name}}") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
billingProject := "" | ||
|
||
if config.BillingProject != "" { | ||
billingProject = config.BillingProject | ||
} | ||
|
||
_, err = sendRequest(config, "GET", billingProject, url, config.userAgent, nil) | ||
if err == nil { | ||
return fmt.Errorf("DialogflowCXFlow still exists at %s", url) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package google | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDialogflowCXFlow_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"org_id": getTestOrgFromEnv(t), | ||
"billing_account": getTestBillingAccountFromEnv(t), | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDialogflowCXFlow_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_dialogflow_cx_flow.my_flow", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccDialogflowCXFlow_full(context), | ||
}, | ||
{ | ||
ResourceName: "google_dialogflow_cx_flow.my_flow", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDialogflowCXFlow_basic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_service_account" "dialogflowcx_service_account" { | ||
account_id = "tf-test-dialogflow-%{random_suffix}" | ||
} | ||
resource "google_project_iam_member" "agent_create" { | ||
role = "roles/dialogflow.admin" | ||
member = "serviceAccount:${google_service_account.dialogflowcx_service_account.email}" | ||
} | ||
resource "google_dialogflow_cx_agent" "agent_entity" { | ||
display_name = "tf-test-%{random_suffix}" | ||
location = "global" | ||
default_language_code = "en" | ||
supported_language_codes = ["fr","de","es"] | ||
time_zone = "America/New_York" | ||
description = "Description 1." | ||
avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo.png" | ||
depends_on = [google_project_iam_member.agent_create] | ||
} | ||
resource "google_dialogflow_cx_flow" "my_flow" { | ||
parent = google_dialogflow_cx_agent.agent_entity.id | ||
display_name = "MyFlow" | ||
nlu_settings { | ||
classification_threshold = 0.3 | ||
model_type = "MODEL_TYPE_STANDARD" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccDialogflowCXFlow_full(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_service_account" "dialogflowcx_service_account" { | ||
account_id = "tf-test-dialogflow-%{random_suffix}" | ||
} | ||
resource "google_project_iam_member" "agent_create" { | ||
role = "roles/dialogflow.admin" | ||
member = "serviceAccount:${google_service_account.dialogflowcx_service_account.email}" | ||
} | ||
resource "google_dialogflow_cx_agent" "agent_entity" { | ||
display_name = "tf-test-%{random_suffix}update" | ||
location = "global" | ||
default_language_code = "en" | ||
supported_language_codes = ["no"] | ||
time_zone = "Europe/London" | ||
description = "Description 2!" | ||
avatar_uri = "https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo-2.png" | ||
enable_stackdriver_logging = true | ||
enable_spell_correction = true | ||
speech_to_text_settings { | ||
enable_speech_adaptation = true | ||
} | ||
depends_on = [google_project_iam_member.agent_create] | ||
} | ||
resource "google_dialogflow_cx_flow" "my_flow" { | ||
parent = google_dialogflow_cx_agent.agent_entity.id | ||
display_name = "MyFlow" | ||
nlu_settings { | ||
classification_threshold = 0.3 | ||
model_type = "MODEL_TYPE_STANDARD" | ||
} | ||
event_handlers { | ||
event = "custom-event" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["I didn't get that. Can you say it again?"] | ||
} | ||
} | ||
} | ||
} | ||
event_handlers { | ||
event = "sys.no-match-default" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["Sorry, could you say that again?"] | ||
} | ||
} | ||
} | ||
} | ||
event_handlers { | ||
event = "sys.no-input-default" | ||
trigger_fulfillment { | ||
return_partial_responses = false | ||
messages { | ||
text { | ||
text = ["One more time?"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.