Skip to content

Commit

Permalink
fix: fixed test case in client_test.go by removing it as it is no lon…
Browse files Browse the repository at this point in the history
…ger useful

Signed-off-by: Alwin Zomotor <[email protected]>
  • Loading branch information
CRAlwin committed Sep 9, 2024
1 parent 1ea1f13 commit 853e30e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pkg/castor/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func (c *Client) GetTuples(count int32, tt TupleType, requestID uuid.UUID) ([]by
}
bodyBytes, err := ioutil.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {

if err != nil {
return nil, err
}
return nil, fmt.Errorf("getting tuples failed for \"%s\" with response code #%d: %s", req.URL, resp.StatusCode, string(bodyBytes))
}
if err != nil {
if err != nil { //|| (int32(len(bodyBytes)) != count*int32(tt.Arity)*2) {
return nil, fmt.Errorf("castor has returned an invalid response body: %s", err)
}
return bodyBytes, nil
Expand Down
19 changes: 4 additions & 15 deletions pkg/castor/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ var _ = Describe("Castor", func() {
})
Context("when the path is correct", func() {
It("returns tuples", func() {
mockedRT := MockedRoundTripper{ExpectedPath: "/intra-vcp/tuples", ReturnJSON: jsn, ExpectedResponseCode: http.StatusOK}
tbytelist := []byte{1, 2, 1, 2}
mockedRT := MockedRoundTripper{ExpectedPath: "/intra-vcp/tuples", ReturnJSON: tbytelist, ExpectedResponseCode: http.StatusOK}
httpClient := &http.Client{Transport: &mockedRT}

client := Client{URL: myURL, HTTPClient: httpClient}
tuples, err := client.GetTuples(0, BitGfp, uuid.MustParse("acc23dc8-7855-4a2f-bc89-494ba30a74d2"))
tuples, err := client.GetTuples(2, BitGfp, uuid.MustParse("acc23dc8-7855-4a2f-bc89-494ba30a74d2"))

Expect(tuples).To(Equal(tupleList))
Expect(tuples).To(Equal(jsn))
Expect(err).NotTo(HaveOccurred())
})
})
Expand All @@ -90,18 +91,6 @@ var _ = Describe("Castor", func() {
Expect(checkHTTPError(err.Error(), "communication with castor failed")).To(BeTrue())
})
})
Context("when castor returns invalid json body", func() {
It("returns an error", func() {
jsn = []byte("invalid JSON String")
mockedRT := MockedRoundTripper{ExpectedPath: "/intra-vcp/tuples", ReturnJSON: jsn, ExpectedResponseCode: http.StatusOK}
httpClient := &http.Client{Transport: &mockedRT}

client := Client{URL: myURL, HTTPClient: httpClient}
_, err := client.GetTuples(0, BitGfp, uuid.MustParse("acc23dc8-7855-4a2f-bc89-494ba30a74d2"))

Expect(checkHTTPError(err.Error(), "castor has returned an invalid response body")).To(BeTrue())
})
})

})

Expand Down

0 comments on commit 853e30e

Please sign in to comment.