Skip to content

Commit

Permalink
Changing some code according to golint
Browse files Browse the repository at this point in the history
  • Loading branch information
leogtzr committed Jun 10, 2018
1 parent ade61c9 commit 563e3aa
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
22 changes: 11 additions & 11 deletions gobank_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ import (
"github.com/parnurzeal/gorequest"
)

var MountebankUri string
var MountebankURI string

func TestMountebank(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Mountebank Integration Test Suite")
}

var _ = BeforeSuite(func() {
MountebankUri = os.Getenv("MOUNTEBANK_URI")
if len(MountebankUri) == 0 {
MountebankUri = "http://localhost:2525"
MountebankURI = os.Getenv("MOUNTEBANK_URI")
if len(MountebankURI) == 0 {
MountebankURI = "http://localhost:2525"
}

Expect(isMountebankRunning(MountebankUri)).To(BeTrue(), "Mountebank is not running")
Expect(isMountebankRunning(MountebankURI)).To(BeTrue(), "Mountebank is not running")

truncateMountebank(MountebankUri)
truncateMountebank(MountebankURI)
})

var _ = AfterSuite(func() {
})

func isMountebankRunning(mountebankBaseUri string) bool {
resp, _, errs := gorequest.New().Get(mountebankBaseUri).End()
func isMountebankRunning(mountebankBaseURI string) bool {
resp, _, errs := gorequest.New().Get(mountebankBaseURI).End()

Expect(errs).To(HaveLen(0))

return resp.StatusCode == http.StatusOK
}

func truncateMountebank(mountebankBaseUri string) {
impostersUri := mountebankBaseUri + "/imposters"
gorequest.New().Delete(impostersUri).End()
func truncateMountebank(mountebankBaseURI string) {
impostersURI := mountebankBaseURI + "/imposters"
gorequest.New().Delete(impostersURI).End()
}
18 changes: 9 additions & 9 deletions mountebank.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

type Client struct {
mountebankUri string
impostersUri string
mountebankURI string
impostersURI string
}

func NewClient(mountebankUri string) *Client {
func NewClient(mountebankURI string) *Client {
return &Client{
mountebankUri: mountebankUri,
impostersUri: mountebankUri + "/imposters",
mountebankURI: mountebankURI,
impostersURI: mountebankURI + "/imposters",
}
}

func (c *Client) CreateImposter(imposter ImposterElement) (map[string]interface{}, error) {
resp, body, errs := gorequest.New().Post(c.impostersUri).Send(imposter).EndBytes()
resp, body, errs := gorequest.New().Post(c.impostersURI).Send(imposter).EndBytes()

if len(errs) > 0 {
return nil, errs[0]
Expand All @@ -39,9 +39,9 @@ func (c *Client) CreateImposter(imposter ImposterElement) (map[string]interface{
}

func (c *Client) DeleteImposter(port int) (map[string]interface{}, error) {
imposterUri := c.impostersUri + "/" + strconv.Itoa(port)
imposterURI := c.impostersURI + "/" + strconv.Itoa(port)

resp, body, errs := gorequest.New().Delete(imposterUri).EndBytes()
resp, body, errs := gorequest.New().Delete(imposterURI).EndBytes()

if len(errs) > 0 {
return nil, errs[0]
Expand All @@ -58,7 +58,7 @@ func (c *Client) DeleteImposter(port int) (map[string]interface{}, error) {
}

func (c *Client) DeleteAllImposters() (map[string]interface{}, error) {
resp, body, errs := gorequest.New().Delete(c.impostersUri).EndBytes()
resp, body, errs := gorequest.New().Delete(c.impostersURI).EndBytes()

if len(errs) > 0 {
return nil, errs[0]
Expand Down
18 changes: 9 additions & 9 deletions mountebank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ var _ = Describe("Mountebank Client", func() {

expectedImposter = gobank.NewImposterBuilder().Protocol(protocol).Port(port).Name("Greeting Imposter").Stubs(stub).Build()

client := gobank.NewClient(MountebankUri)
client := gobank.NewClient(MountebankURI)
createdImposter, err = client.CreateImposter(expectedImposter)
log.Println("ActualImposter: ", createdImposter)
})
})

It("should have the Imposter installed on Mountebank", func() {
imposterUri := MountebankUri + "/imposters/" + strconv.Itoa(port)
resp, body, _ := gorequest.New().Get(imposterUri).End()
imposterURI := MountebankURI + "/imposters/" + strconv.Itoa(port)
resp, body, _ := gorequest.New().Get(imposterURI).End()

log.Println("Imposter from Mountebank. Body: ", body)
Expect(resp.StatusCode).To(Equal(http.StatusOK))
Expand Down Expand Up @@ -91,16 +91,16 @@ var _ = Describe("Mountebank Client", func() {
BeforeEach(func() {
once.Do(func() {
imposter := gobank.NewImposterBuilder().Protocol(protocol).Port(port).Build()
client := gobank.NewClient(MountebankUri)
client := gobank.NewClient(MountebankURI)
client.CreateImposter(imposter)

deletedImposter, err = client.DeleteImposter(port)
})
})

It("should delete the installed Imposter at Mountebank", func() {
imposterUri := MountebankUri + "/imposters/" + strconv.Itoa(port)
resp, _, _ := gorequest.New().Get(imposterUri).End()
imposterURI := MountebankURI + "/imposters/" + strconv.Itoa(port)
resp, _, _ := gorequest.New().Get(imposterURI).End()

Expect(resp.StatusCode).To(Equal(http.StatusNotFound))
})
Expand Down Expand Up @@ -131,7 +131,7 @@ var _ = Describe("Mountebank Client", func() {
imposter1 := gobank.NewImposterBuilder().Protocol(protocol).Build()
imposter2 := gobank.NewImposterBuilder().Protocol(protocol).Build()

client := gobank.NewClient(MountebankUri)
client := gobank.NewClient(MountebankURI)
client.CreateImposter(imposter1)
client.CreateImposter(imposter2)

Expand All @@ -140,8 +140,8 @@ var _ = Describe("Mountebank Client", func() {
})

It("should delete all the installed Imposters at Mountebank", func() {
impostersUri := MountebankUri + "/imposters"
resp, _, _ := gorequest.New().Get(impostersUri).End()
impostersURI := MountebankURI + "/imposters"
resp, _, _ := gorequest.New().Get(impostersURI).End()

Expect(resp.StatusCode).To(Equal(http.StatusOK))
})
Expand Down
6 changes: 3 additions & 3 deletions predicates/contains.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p contains) Type() string {
func (p contains) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
containsJson := " { \"contains\" : " + requestJson + "}"
requestJSON := string(requestBytes)
containsJSON := " { \"contains\" : " + requestJSON + "}"

return []byte(containsJson), nil
return []byte(containsJSON), nil
}

type ContainsBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/deepEquals.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p deepEquals) Type() string {
func (p deepEquals) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
deepEqualsJson := " { \"deepEquals\" : " + requestJson + "}"
requestJSON := string(requestBytes)
deepEqualsJSON := " { \"deepEquals\" : " + requestJSON + "}"

return []byte(deepEqualsJson), nil
return []byte(deepEqualsJSON), nil
}

type DeepEqualsBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/endsWith.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p endsWith) Type() string {
func (p endsWith) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
endsWithJson := " { \"endsWith\" : " + requestJson + "}"
requestJSON := string(requestBytes)
endsWithJSON := " { \"endsWith\" : " + requestJSON + "}"

return []byte(endsWithJson), nil
return []byte(endsWithJSON), nil
}

type EndsWithBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/equals.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p equals) Type() string {
func (p equals) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
equalsJson := " { \"equals\" : " + requestJson + "}"
requestJSON := string(requestBytes)
equalsJSON := " { \"equals\" : " + equalsJSON + "}"

return []byte(equalsJson), nil
return []byte(equalsJSON), nil
}

type EqualsBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func (p exists) Type() string {
func (p exists) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
existsJson := " { \"exists\" : " + requestJson + "}"
requestJSON := string(requestBytes)
existsJSON := " { \"exists\" : " + requestJSON + "}"

return []byte(existsJson), nil
return []byte(existsJSON), nil
}

type ExistsBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p matches) Type() string {
func (p matches) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
matchesJson := " { \"matches\" : " + requestJson + "}"
requestJSON := string(requestBytes)
matchesJSON := " { \"matches\" : " + requestJSON + "}"

return []byte(matchesJson), nil
return []byte(matchesJSON), nil
}

type MatchesBuilder struct {
Expand Down
6 changes: 3 additions & 3 deletions predicates/startsWith.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func (p startsWith) Type() string {
func (p startsWith) MarshalJSON() ([]byte, error) {
requestBytes, _ := json.Marshal(p.req)

requestJson := string(requestBytes)
startsWithJson := " { \"startsWith\" : " + requestJson + "}"
requestJSON := string(requestBytes)
startsWithJSON := " { \"startsWith\" : " + requestJSON + "}"

return []byte(startsWithJson), nil
return []byte(startsWithJSON), nil
}

type StartsWithBuilder struct {
Expand Down

0 comments on commit 563e3aa

Please sign in to comment.