-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport: Revert Enforcement type (#211)
This commit is for a separate backported release of the following fix, for the 0.13.x series of the client. In #197 we changed the type of Policy.Enforce from []*Enforcement to []Enforcement. This had downstream impact on the terraform-provider, which relies on this client (as well as any other 3rd parties that use this client!) This PR primarily reverts the type changes of Policy.Enforce back to being a []*Enforcement. It also updates the hashicorp/jsonapi package to reference the latest version. It also includes a field tag change necessary from #209
- Loading branch information
1 parent
fdcbf1a
commit a6c7584
Showing
6 changed files
with
75 additions
and
71 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
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
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
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
package tfe | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
@@ -319,59 +316,3 @@ func TestNotificationConfigurationVerify(t *testing.T) { | |
assert.EqualError(t, err, "invalid value for notification configuration ID") | ||
}) | ||
} | ||
|
||
func TestNotificationConfiguration_Unmarshal(t *testing.T) { | ||
headers := map[string][]string{ | ||
"cache-control": {"private"}, | ||
"content-length": {"129"}, | ||
} | ||
data := map[string]interface{}{ | ||
"data": map[string]interface{}{ | ||
"type": "notification-configurations", | ||
"id": "nc-ntv3HbhJqvFzamy7", | ||
"attributes": map[string]interface{}{ | ||
"created-at": "2018-03-02T23:42:06.651Z", | ||
"delivery-responses": []interface{}{ | ||
map[string]interface{}{ | ||
"body": "html", | ||
"code": "200", | ||
"headers": headers, | ||
"sent-at": "2021-03-23T17:13:52+00:00", | ||
"successful": "true", | ||
"url": "hashicorp.com", | ||
}, | ||
}, | ||
"destination-type": NotificationDestinationTypeEmail, | ||
"enabled": true, | ||
"name": "general", | ||
"token": "secret", | ||
"triggers": []string{"run:applying", "run:completed"}, | ||
"url": "hashicorp.com", | ||
"email-addresses": []string{"[email protected]"}, | ||
}, | ||
}, | ||
} | ||
byteData, err := json.Marshal(data) | ||
require.NoError(t, err) | ||
|
||
responseBody := bytes.NewReader(byteData) | ||
nc := &NotificationConfiguration{} | ||
err = unmarshalResponse(responseBody, nc) | ||
require.NoError(t, err) | ||
|
||
iso8601TimeFormat := "2006-01-02T15:04:05Z" | ||
parsedTime, err := time.Parse(iso8601TimeFormat, "2018-03-02T23:42:06.651Z") | ||
require.NoError(t, err) | ||
sentAtTime, err := time.Parse(time.RFC3339, "2021-03-23T17:13:52+00:00") | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, nc.ID, "nc-ntv3HbhJqvFzamy7") | ||
assert.Equal(t, nc.CreatedAt, parsedTime) | ||
assert.Equal(t, len(nc.DeliveryResponses), 1) | ||
assert.Equal(t, "html", nc.DeliveryResponses[0].Body) | ||
assert.Equal(t, "200", nc.DeliveryResponses[0].Code) | ||
assert.Equal(t, "true", nc.DeliveryResponses[0].Successful) | ||
assert.Equal(t, sentAtTime, nc.DeliveryResponses[0].SentAt) | ||
assert.Equal(t, []string{"129"}, nc.DeliveryResponses[0].Headers["content-length"]) | ||
assert.Equal(t, []string{"private"}, nc.DeliveryResponses[0].Headers["cache-control"]) | ||
} |
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
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