Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
avnerenv0 committed Jan 3, 2022
1 parent 7024fea commit 67d139d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/configuration_variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ var _ = Describe("Configuration Variable", func() {
return request
}

var DoCreateRequest = func(mockConfig ConfigurationVariable, expectedRequest []map[string]interface{}) {
var SetCreateRequestExpectation = func(mockConfig ConfigurationVariable) {
expectedCreateRequest := GetExpectedRequest(mockConfig)
httpCall = mockHttpClient.EXPECT().
Post("configuration", expectedRequest, gomock.Any()).
Post("configuration", expectedCreateRequest, gomock.Any()).
Do(func(path string, request interface{}, response *[]ConfigurationVariable) {
*response = []ConfigurationVariable{mockConfig}
})
}

var DoCreateRequest = func(mockConfig ConfigurationVariable) {
createdConfigurationVariable, _ = apiClient.ConfigurationVariableCreate(
ConfigurationVariableCreateParams{
Name: mockConfig.Name,
Expand All @@ -81,8 +84,8 @@ var _ = Describe("Configuration Variable", func() {

BeforeEach(func() {
mockOrganizationIdCall(organizationId)
expectedCreateRequest := GetExpectedRequest(mockConfigurationVariable)
DoCreateRequest(mockConfigurationVariable, expectedCreateRequest)
SetCreateRequestExpectation(mockConfigurationVariable)
DoCreateRequest(mockConfigurationVariable)
})

It("Should get organization id", func() {
Expand All @@ -101,9 +104,9 @@ var _ = Describe("Configuration Variable", func() {
var mockWithFormat = ConfigurationVariable{}
copier.Copy(&mockWithFormat, &mockConfigurationVariable)
mockWithFormat.Schema.Format = schemaFormat
requestWithFormat := GetExpectedRequest(mockWithFormat)
SetCreateRequestExpectation(mockWithFormat)

DoCreateRequest(mockWithFormat, requestWithFormat)
DoCreateRequest(mockWithFormat)

httpCall.Times(1)
Expect(createdConfigurationVariable).To(Equal(mockWithFormat))
Expand Down

0 comments on commit 67d139d

Please sign in to comment.