Skip to content

Commit

Permalink
better test
Browse files Browse the repository at this point in the history
  • Loading branch information
avnerenv0 committed May 31, 2021
1 parent 16698cf commit 4f8e41a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions client/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ import (

. "github.com/env0/terraform-provider-env0/client"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
)

var _ = Describe("Models", func() {
Describe("TemplateCreatePayload", func() {
It("Should omit Github Installation Id when it's not there", func() {
payload := TemplateCreatePayload{}
jsonPayload, _ := json.Marshal(payload)
var parsedPayload map[string]interface{}
json.Unmarshal(jsonPayload, &parsedPayload)
Expect(parsedPayload["githubInstallationId"]).To(BeNil())
})
DescribeTable("Github Installation Id",
func(value int, expected types.GomegaMatcher) {
payload := TemplateCreatePayload{
GithubInstallationId: value,
}
jsonPayload, _ := json.Marshal(payload)
var parsedPayload map[string]interface{}
json.Unmarshal(jsonPayload, &parsedPayload)
Expect(parsedPayload["githubInstallationId"]).To(expected)
},
Entry("Has value", 123, BeEquivalentTo(123)),
Entry("No value", nil, BeNil()),
)
})
})

0 comments on commit 4f8e41a

Please sign in to comment.