diff --git a/README.md b/README.md index 60cabe9..b625ba1 100644 --- a/README.md +++ b/README.md @@ -1032,7 +1032,7 @@ Anyone is welcome to contribute. - Open an issue or discussion post to track the effort - Fork this repository, then clone it - Place this in your own module's `go.mod` to enable testing local changes - - `replace github.com/k-capehart/go-salesforce => /path_to_local_fork/` + - `replace github.com/k-capehart/go-salesforce/v2 => /path_to_local_fork/` - Run tests - `go test -cover` - Generate code coverage output diff --git a/salesforce.go b/salesforce.go index e6fe025..6888cad 100644 --- a/salesforce.go +++ b/salesforce.go @@ -76,7 +76,7 @@ func doRequest(auth *authentication, payload requestPayload) (*http.Response, er if err != nil { return resp, err } - if resp.StatusCode < 200 || resp.StatusCode > 299 { + if resp.StatusCode < 200 || resp.StatusCode > 300 { resp, err = processSalesforceError(*resp, auth, payload) } diff --git a/salesforce_test.go b/salesforce_test.go index 3ed80ab..56a8c71 100644 --- a/salesforce_test.go +++ b/salesforce_test.go @@ -38,9 +38,14 @@ func setupTestServer(body any, status int) (*httptest.Server, authentication) { func Test_doRequest(t *testing.T) { server, sfAuth := setupTestServer("", http.StatusOK) defer server.Close() + badServer, badSfAuth := setupTestServer("", http.StatusBadRequest) defer badServer.Close() + recordArrayResp := [2]string{"testRecord1", "testRecord2"} + serverWith300Resp, authWith300Resp := setupTestServer(recordArrayResp, http.StatusMultipleChoices) + defer serverWith300Resp.Close() + type args struct { auth *authentication payload requestPayload @@ -79,6 +84,20 @@ func Test_doRequest(t *testing.T) { want: http.StatusBadRequest, wantErr: true, }, + { + name: "handle_multiple_records_with_same_externalId_statusCode_300", + args: args{ + auth: &authWith300Resp, + payload: requestPayload{ + method: http.MethodGet, + uri: "/sobjects/Contact/ContactExternalId__c/Avng1", + content: jsonType, + body: "", + }, + }, + want: http.StatusMultipleChoices, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {