forked from cheelim1/terraform-provider-jumpcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm util module, add implementation comments, make attributes worthy o…
…f resource renewal, switch to sdk fake patch op
- Loading branch information
1 parent
a3f5b64
commit db24469
Showing
3 changed files
with
83 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package jumpcloud | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
jcapiv2 "github.com/TheJumpCloud/jcapi-go/v2" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ResourceUserGroupSuite struct { | ||
suite.Suite | ||
A *assert.Assertions | ||
TestHTTPServer *httptest.Server | ||
} | ||
|
||
func (s *ResourceUserGroupSuite) SetupSuite() { | ||
s.A = assert.New(s.Suite.T()) | ||
} | ||
|
||
func (s *ResourceUserGroupSuite) TestTrueUserGroupRead() { | ||
cases := []struct { | ||
ResponseStatus int | ||
UserGroupNil bool | ||
OK bool | ||
ErrorNil bool | ||
Payload []byte | ||
}{ | ||
{http.StatusNotFound, true, false, true, []byte("irrelevant")}, | ||
{http.StatusOK, false, true, true, []byte("{}")}, | ||
} | ||
|
||
for _, c := range cases { | ||
testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||
rw.WriteHeader(c.ResponseStatus) | ||
rw.Write(c.Payload) | ||
})) | ||
|
||
config := &jcapiv2.Configuration{ | ||
BasePath: testServer.URL, | ||
} | ||
|
||
ug, ok, err := userGroupReadHelper(config, "id") | ||
s.A.Equal(c.OK, ok) | ||
s.A.Equal(c.UserGroupNil, ug == nil) | ||
s.A.Equal(c.ErrorNil, err == nil) | ||
testServer.Close() | ||
} | ||
} | ||
|
||
func TestResourceUserGroup(t *testing.T) { | ||
suite.Run(t, new(ResourceUserGroupSuite)) | ||
} |
This file was deleted.
Oops, something went wrong.