Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #97 from maximilien/develop
Browse files Browse the repository at this point in the history
All changes from Max and Matt: mainly around adding HTTP error code handling and getting pipeline to go green
  • Loading branch information
maximilien committed Mar 10, 2016
2 parents ab518f4 + c5880c7 commit 6436296
Show file tree
Hide file tree
Showing 40 changed files with 3,419 additions and 562 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _obj
_test
tmp
out
.idea

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
4 changes: 2 additions & 2 deletions bin/test_integration
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
cd $base

echo -e "\n Integration Testing packages:"
ginkgo -r -p -v --noisyPendings integration
ginkgo -r -p -v --noisyPendings=false -skipPackage=dns_domain integration

echo -e "\n Vetting packages for potential issues..."
go tool vet services data_types main client common test_helpers integration
)
)
41 changes: 41 additions & 0 deletions ci/pipelines/concourse.yml
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



41 changes: 41 additions & 0 deletions ci/pipelines/concourse_dev.yml
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



140 changes: 140 additions & 0 deletions client/fakes/http_client_fake.go
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
}
}
Loading

0 comments on commit 6436296

Please sign in to comment.