Skip to content

Commit

Permalink
Merge pull request #832 from hashicorp/stefan-kiss/main
Browse files Browse the repository at this point in the history
Local branch for #824
  • Loading branch information
brandonc authored Jan 2, 2024
2 parents a0264fe + e534fda commit ab34263
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased

## Enhancements

* Added `Sentinel` field to `PolicyResult` by @stefan-kiss. [Issue#790](https://github.com/hashicorp/go-tfe/issues/790)

# v1.41.0

## Enhancements
Expand Down
1 change: 1 addition & 0 deletions policy_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type PolicyResult struct {
Result bool `jsonapi:"attr,result"`
SoftFailed int `jsonapi:"attr,soft-failed"`
TotalFailed int `jsonapi:"attr,total-failed"`
Sentinel any `jsonapi:"attr,sentinel"`
}

// PolicyStatusTimestamps holds the timestamps for individual policy check
Expand Down
8 changes: 6 additions & 2 deletions policy_check_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"encoding/json"
"io"
"reflect"
"testing"
"time"

Expand Down Expand Up @@ -80,8 +81,6 @@ func TestPolicyChecksList(t *testing.T) {
}

func TestPolicyChecksRead(t *testing.T) {
skipIfEnterprise(t)

client := testClient(t)
ctx := context.Background()

Expand All @@ -106,6 +105,11 @@ func TestPolicyChecksRead(t *testing.T) {
assert.NotEmpty(t, pc.StatusTimestamps)
assert.Equal(t, 1, pc.Result.Passed)
assert.NotEmpty(t, pc.Run)
assert.NotEmpty(t, pc.Result.Sentinel)

if reflect.TypeOf(pc.Result.Sentinel) != reflect.TypeOf(map[string]interface{}{}) {
assert.Fail(t, "Sentinel is not a map[string]interface{}")
}
})

t.Run("when the policy check does not exist", func(t *testing.T) {
Expand Down

0 comments on commit ab34263

Please sign in to comment.