Skip to content

Commit

Permalink
Merge pull request #63 from env0/fix-github-installation-id-zero
Browse files Browse the repository at this point in the history
Fix: Template creation model to omit empty github installation id
  • Loading branch information
roni-frantchi committed May 31, 2021
2 parents b06e0f2 + 4f8e41a commit 2575fc8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
6 changes: 3 additions & 3 deletions client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type Project struct {
}

type UpdateProjectPayload struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
}

type ConfigurationVariableSchema struct {
Expand Down Expand Up @@ -107,7 +107,7 @@ type TemplateCreatePayload struct {
IsGitLab bool `json:"isGitLab"`
TokenName string `json:"tokenName"`
TokenId string `json:"tokenId"`
GithubInstallationId int `json:"githubInstallationId"`
GithubInstallationId int `json:"githubInstallationId,omitempty"`
Revision string `json:"revision"`
ProjectIds []string `json:"projectIds,omitempty"`
OrganizationId string `json:"organizationId"`
Expand Down
29 changes: 29 additions & 0 deletions client/model_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package client_test

import (
"encoding/json"

. "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() {
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()),
)
})
})
10 changes: 5 additions & 5 deletions tests/integration/005_ssh_key/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ output "name" {
}

resource "env0_template" "usage" {
name = "use a ssh key"
description = "use a ssh key"
type = "terraform"
repository = "https://github.com/shlomimatichin/env0-template-jupyter-gpu"
ssh_keys = [env0_ssh_key.tested]
name = "use a ssh key"
description = "use a ssh key"
type = "terraform"
repository = "https://github.com/shlomimatichin/env0-template-jupyter-gpu"
ssh_keys = [env0_ssh_key.tested]
}

0 comments on commit 2575fc8

Please sign in to comment.