This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from maximilien/develop
All changes from Max and Matt: mainly around adding HTTP error code handling and getting pipeline to go green
- Loading branch information
Showing
40 changed files
with
3,419 additions
and
562 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ _obj | |
_test | ||
tmp | ||
out | ||
.idea | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
|
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,41 @@ | ||
resources: | ||
- name: softlayer-go | ||
type: git | ||
source: | ||
uri: https://github.com/maximilien/softlayer-go.git | ||
branch: master | ||
|
||
jobs: | ||
- name: sl-go-unit | ||
public: true | ||
plan: | ||
- get: softlayer-go | ||
trigger: true | ||
- task: unit | ||
file: softlayer-go/ci/unit.yml | ||
config: | ||
params: | ||
SL_USERNAME: fake-username | ||
SL_API_KEY: fake-api-key | ||
|
||
- name: sl-go-integration | ||
plan: | ||
- get: softlayer-go | ||
trigger: true | ||
passed: [sl-go-unit] | ||
- task: integration | ||
file: softlayer-go/ci/integration.yml | ||
config: | ||
params: | ||
SL_USERNAME: {{SL_USERNAME}} | ||
SL_API_KEY: {{SL_API_KEY}} | ||
SL_DATACENTER: {{SL_DATACENTER}} | ||
|
||
groups: | ||
- name: softlayer-go | ||
jobs: | ||
- sl-go-unit | ||
- sl-go-integration | ||
|
||
|
||
|
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,41 @@ | ||
resources: | ||
- name: softlayer-go | ||
type: git | ||
source: | ||
uri: https://github.com/maximilien/softlayer-go.git | ||
branch: develop | ||
|
||
jobs: | ||
- name: sl-go-unit | ||
public: true | ||
plan: | ||
- get: softlayer-go | ||
trigger: true | ||
- task: unit | ||
file: softlayer-go/ci/unit.yml | ||
config: | ||
params: | ||
SL_USERNAME: fake-username | ||
SL_API_KEY: fake-api-key | ||
|
||
- name: sl-go-integration | ||
plan: | ||
- get: softlayer-go | ||
passed: [sl-go-unit] | ||
trigger: true | ||
- task: integration | ||
file: softlayer-go/ci/integration.yml | ||
config: | ||
params: | ||
SL_USERNAME: {{SL_USERNAME}} | ||
SL_API_KEY: {{SL_API_KEY}} | ||
SL_DATACENTER: {{SL_DATACENTER}} | ||
|
||
groups: | ||
- name: softlayer-go | ||
jobs: | ||
- sl-go-unit | ||
- sl-go-integration | ||
|
||
|
||
|
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,140 @@ | ||
package client_fakes | ||
|
||
import ( | ||
"bytes" | ||
) | ||
|
||
type FakeHttpClient struct { | ||
Username string | ||
ApiKey string | ||
|
||
DoRawHttpRequestInt int | ||
DoRawHttpRequestError error | ||
DoRawHttpRequestResponse []byte | ||
DoRawHttpRequestResponses [][]byte | ||
DoRawHttpRequestResponsesCount int | ||
DoRawHttpRequestResponsesIndex int | ||
|
||
//DoRawHttpRequest | ||
DoRawHttpRequestPath string | ||
DoRawHttpRequestRequestType string | ||
DoRawHttpRequestRequestBody *bytes.Buffer | ||
|
||
//DoRawHttpRequestWithObject | ||
DoRawHttpRequestWithObjectMaskPath string | ||
DoRawHttpRequestWithObjectMaskMasks []string | ||
DoRawHttpRequestWithObjectMaskRequestType string | ||
DoRawHttpRequestWithObjectMaskRequestBody *bytes.Buffer | ||
|
||
//DoRawHttpRequestWithObjectFilter | ||
DoRawHttpRequestWithObjectFilterPath string | ||
DoRawHttpRequestWithObjectFilterFilters string | ||
DoRawHttpRequestWithObjectFilterRequestType string | ||
DoRawHttpRequestWithObjectFilterRequestBody *bytes.Buffer | ||
|
||
//DoRawHttpRequestWithObjectFilterAndObjectMask | ||
DoRawHttpRequestWithObjectFilterAndObjectMaskPath string | ||
DoRawHttpRequestWithObjectFilterAndObjectMaskMasks []string | ||
DoRawHttpRequestWithObjectFilterAndObjectMaskFilters string | ||
DoRawHttpRequestWithObjectFilterAndObjectMaskRequestType string | ||
DoRawHttpRequestWithObjectFilterAndObjectMaskRequestBody *bytes.Buffer | ||
|
||
//GenerateRequest | ||
GenerateRequestBodyTemplateData interface{} | ||
GenerateRequestBodyBuffer *bytes.Buffer | ||
GenerateRequestBodyError error | ||
|
||
//HasErrors | ||
HasErrorsBody map[string]interface{} | ||
HasErrorsError error | ||
|
||
//CheclForHttpResponseErrors | ||
CheckForHttpResponseErrorsData []byte | ||
CheckForHttpResponseErrorsError error | ||
} | ||
|
||
func NewFakeHttpClient(username, apiKey string) *FakeHttpClient { | ||
return &FakeHttpClient{ | ||
Username: username, | ||
ApiKey: apiKey, | ||
|
||
DoRawHttpRequestInt: 200, | ||
DoRawHttpRequestError: nil, | ||
DoRawHttpRequestResponses: [][]byte{}, | ||
DoRawHttpRequestResponsesCount: 0, | ||
DoRawHttpRequestResponsesIndex: 0, | ||
} | ||
} | ||
|
||
//softlayer.HttpClient interface methods | ||
|
||
func (fhc *FakeHttpClient) DoRawHttpRequest(path string, requestType string, requestBody *bytes.Buffer) ([]byte, int, error) { | ||
fhc.DoRawHttpRequestPath = path | ||
fhc.DoRawHttpRequestRequestType = requestType | ||
fhc.DoRawHttpRequestRequestBody = requestBody | ||
|
||
return fhc.processResponse() | ||
} | ||
|
||
func (fhc *FakeHttpClient) DoRawHttpRequestWithObjectMask(path string, masks []string, requestType string, requestBody *bytes.Buffer) ([]byte, int, error) { | ||
fhc.DoRawHttpRequestWithObjectMaskPath = path | ||
fhc.DoRawHttpRequestWithObjectMaskMasks = masks | ||
fhc.DoRawHttpRequestWithObjectMaskRequestType = requestType | ||
fhc.DoRawHttpRequestWithObjectMaskRequestBody = requestBody | ||
|
||
return fhc.processResponse() | ||
} | ||
|
||
func (fhc *FakeHttpClient) DoRawHttpRequestWithObjectFilter(path string, filters string, requestType string, requestBody *bytes.Buffer) ([]byte, int, error) { | ||
fhc.DoRawHttpRequestWithObjectFilterPath = path | ||
fhc.DoRawHttpRequestWithObjectFilterFilters = filters | ||
fhc.DoRawHttpRequestWithObjectFilterRequestType = requestType | ||
fhc.DoRawHttpRequestWithObjectFilterRequestBody = requestBody | ||
|
||
return fhc.processResponse() | ||
} | ||
|
||
func (fhc *FakeHttpClient) DoRawHttpRequestWithObjectFilterAndObjectMask(path string, masks []string, filters string, requestType string, requestBody *bytes.Buffer) ([]byte, int, error) { | ||
fhc.DoRawHttpRequestWithObjectFilterAndObjectMaskPath = path | ||
fhc.DoRawHttpRequestWithObjectFilterAndObjectMaskMasks = masks | ||
fhc.DoRawHttpRequestWithObjectFilterAndObjectMaskFilters = filters | ||
fhc.DoRawHttpRequestWithObjectFilterAndObjectMaskRequestType = requestType | ||
fhc.DoRawHttpRequestWithObjectFilterAndObjectMaskRequestBody = requestBody | ||
|
||
return fhc.processResponse() | ||
} | ||
|
||
func (fhc *FakeHttpClient) GenerateRequestBody(templateData interface{}) (*bytes.Buffer, error) { | ||
fhc.GenerateRequestBodyTemplateData = templateData | ||
|
||
return fhc.GenerateRequestBodyBuffer, fhc.GenerateRequestBodyError | ||
} | ||
|
||
func (fhc *FakeHttpClient) HasErrors(body map[string]interface{}) error { | ||
fhc.HasErrorsBody = body | ||
|
||
return fhc.HasErrorsError | ||
} | ||
|
||
func (fhc *FakeHttpClient) CheckForHttpResponseErrors(data []byte) error { | ||
fhc.CheckForHttpResponseErrorsData = data | ||
|
||
return fhc.CheckForHttpResponseErrorsError | ||
} | ||
|
||
// private methods | ||
|
||
func (fhc *FakeHttpClient) processResponse() ([]byte, int, error) { | ||
fhc.DoRawHttpRequestResponsesCount += 1 | ||
|
||
if fhc.DoRawHttpRequestError != nil { | ||
return []byte{}, fhc.DoRawHttpRequestInt, fhc.DoRawHttpRequestError | ||
} | ||
|
||
if fhc.DoRawHttpRequestResponses != nil && len(fhc.DoRawHttpRequestResponses) == 0 { | ||
return fhc.DoRawHttpRequestResponse, fhc.DoRawHttpRequestInt, fhc.DoRawHttpRequestError | ||
} else { | ||
fhc.DoRawHttpRequestResponsesIndex = fhc.DoRawHttpRequestResponsesIndex + 1 | ||
return fhc.DoRawHttpRequestResponses[fhc.DoRawHttpRequestResponsesIndex-1], fhc.DoRawHttpRequestInt, fhc.DoRawHttpRequestError | ||
} | ||
} |
Oops, something went wrong.