k-capehart / go-salesforce

Salesforce REST API client written in Go
https://pkg.go.dev/github.com/k-capehart/go-salesforce/v2
MIT License
24 stars 4 forks source link

improve tests with an helper #46

Open ccoVeille opened 1 month ago

ccoVeille commented 1 month ago

I suggested using this

Oh, I totally missed that, sorry, indeed.

maybe you could code a helper to reuse it, something simple, as any test framework would do.

but maybe something like this

err := doBatchedRequestsForCollection(tt.args.auth, tt.args.method, tt.args.url, tt.args.batchSize, tt.args.recordMap);
checkError(t, tt.wantErr, err, "doBatchedRequestsForCollection")
func checkError(t *testing.T, wantErr bool, err error, method string) {
    t.Helper()

    if wantErr && err != nil {
      return
    }

    if !wantErr && err == nil {
      return
    }

   t.Errorf("%s() error = %v, wantErr %v", method, err, tt.wantErr)
}

But as there is no errors, there might have no need

@k-capehart replied this

I'll have to look into that, thank you. It would have to be part of a different PR though. Feel free to open an Issue or Discussion post about it.

_Originally posted by @k-capehart in https://github.com/k-capehart/go-salesforce/pull/45#discussion_r1657193445_

So I'm opening an issue