Skip to content

[WIP] Sla resource Acc test fixes #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sla_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

resource "zendesk_sla_policy" "incidents_sla_policy" {
title = "Incidents"
active = true

all {
# TODO: this is failing on the ACC test.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nukosuke after looking into this a bit more I think the problem here is that zendesk is translating the input here:

It is taking this:

  all {
    # TODO: this is failing on the ACC test.
    field    = "type"
    operator = "is"
    value    = "incident"
  }

and turning it into something like this

  all {
    # TODO: this is failing on the ACC test.
    field    = "ticket_type_id"
    operator = "is"
    value    = 2
  }

but that said I am not exactly sure of the best way to solve this. Seems like we might have to figure out how to translate the response from zendesk back into the resource listed in the terraform file.

Curious if you have thoughts.

See: https://developer.zendesk.com/rest_api/docs/support/views#additional-sla-policies-conditions

field = "type"
operator = "is"
value = "incident"
Expand Down
22 changes: 6 additions & 16 deletions zendesk/resource_zendesk_sla_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func resourceZendeskSLAPolicy() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"active": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"position": {
Type: schema.TypeInt,
Computed: true,
Expand All @@ -61,12 +56,12 @@ func resourceZendeskSLAPolicy() *schema.Resource {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"agent_work_time",
"first_reply_time",
"next_reply_time",
"pausable_update_time",
"periodic_update_time",
"requester_wait_time",
client.AgentWorkTimeMetric,
client.FirstReplyTimeMetric,
client.NextReplyTimeMetric,
client.PausableUpdateTimeMetric, // TYPO :(
client.PeriodicUpdateTimeMetric,
client.RequesterWaitTimeMetric,
}, false),
},
"target": {
Expand Down Expand Up @@ -95,7 +90,6 @@ func resourceZendeskSLAPolicy() *schema.Resource {
func marshalSLAPolicy(slaPolicy client.SLAPolicy, d identifiableGetterSetter) error {
fields := map[string]interface{}{
"title": slaPolicy.Title,
"active": slaPolicy.Active,
"position": slaPolicy.Position,
"description": slaPolicy.Description,
}
Expand Down Expand Up @@ -153,10 +147,6 @@ func unmarshalSLAPolicy(d identifiableGetterSetter) (client.SLAPolicy, error) {
sla.Title = v.(string)
}

if v, ok := d.GetOk("active"); ok {
sla.Active = v.(bool)
}

if v, ok := d.GetOk("description"); ok {
sla.Description = v.(string)
}
Expand Down
2 changes: 1 addition & 1 deletion zendesk/resource_zendesk_sla_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func TestAccSLAPolicyExample(t *testing.T) {
Config: readExampleConfig(t, "sla_policies.tf"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("zendesk_sla_policy.incidents_sla_policy", "title", "Incidents"),
resource.TestCheckResourceAttr("zendesk_sla_policy.incidents_sla_policy", "active", "true"),
resource.TestCheckResourceAttrSet("zendesk_sla_policy.incidents_sla_policy", "all.#"),
resource.TestCheckResourceAttrSet("zendesk_sla_policy.incidents_sla_policy", "policy_metrics.#"),
),
},
},
Expand Down