Skip to content

Commit

Permalink
added a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Aug 5, 2024
1 parent 69266d3 commit 6e2aaaa
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions client/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,58 @@ var _ = Describe("Organization", func() {
})
})

Describe("OrganizationPolicyUpdate", func() {
hour12 := "12-h"
t := true
updatedMockOrganization := mockOrganization
updatedMockOrganization.DoNotConsiderMergeCommitsForPrPlans = true
updatedMockOrganization.EnableOidc = true
updatedMockOrganization.EnforcePrCommenterPermissions = true
updatedMockOrganization.DefaultTtl = &hour12

var updatedOrganization *Organization
var err error

emptyString := ""

Describe("Emtpy string is passed as null", func() {
BeforeEach(func() {
mockOrganizationIdCall(organizationId)
originalUpdatePayload := OrganizationPolicyUpdatePayload{
DefaultTtl: &emptyString,
MaxTtl: &emptyString,
DoNotConsiderMergeCommitsForPrPlans: &t,
EnableOidc: &t,
EnforcePrCommenterPermissions: &t,
}

sentUpdatePayload := OrganizationPolicyUpdatePayload{
DefaultTtl: nil,
MaxTtl: nil,
DoNotConsiderMergeCommitsForPrPlans: &t,
EnableOidc: &t,
EnforcePrCommenterPermissions: &t,
}

httpCall = mockHttpClient.EXPECT().
Post("/organizations/"+organizationId+"/policies", sentUpdatePayload, gomock.Any()).
Do(func(path string, request interface{}, response *Organization) {
*response = updatedMockOrganization
}).Times(1)

updatedOrganization, err = apiClient.OrganizationPolicyUpdate(originalUpdatePayload)
})

It("Should not return an error", func() {
Expect(err).To(BeNil())
})

It("Should return organization received from API", func() {
Expect(*updatedOrganization).To(Equal(updatedMockOrganization))
})
})
})

Describe("OrganizationUserUpdateRole", func() {
userId := "userId"
roleId := "roleId"
Expand Down

0 comments on commit 6e2aaaa

Please sign in to comment.