diff --git a/backends/rapidpro/log.go b/backends/rapidpro/log.go index d6e7a895e..64ce8cc58 100644 --- a/backends/rapidpro/log.go +++ b/backends/rapidpro/log.go @@ -23,10 +23,13 @@ func writeChannelLog(b *backend, log *courier.ChannelLog) error { description := "Success" if log.Error != "" { - description = fmt.Sprintf("Error: %s", log.Error) + description = "Error" + + // we append our error to our response as it can be long + log.Response += "\n\nError: " + log.Error } - _, err := b.db.Exec(insertLogSQL, dbChan.ID(), log.MsgID, description[:255], log.Error != "", log.Method, log.URL, + _, err := b.db.Exec(insertLogSQL, dbChan.ID(), log.MsgID, description, log.Error != "", log.Method, log.URL, log.Request, log.Response, log.StatusCode, log.CreatedOn, log.Elapsed/time.Millisecond) return err diff --git a/utils/http_test.go b/utils/http_test.go new file mode 100644 index 000000000..160ef0480 --- /dev/null +++ b/utils/http_test.go @@ -0,0 +1,24 @@ +package utils + +import "testing" + +func TestClient(t *testing.T) { + client := GetHTTPClient() + if client == nil { + t.Error("Client should not be nil") + } + + insecureClient := GetInsecureHTTPClient() + if insecureClient == nil { + t.Error("Insecure client should not be nil") + } + + if client == insecureClient || client.Transport == insecureClient.Transport { + t.Error("Client and insecure client should not be the same") + } + + client2 := GetHTTPClient() + if client != client2 { + t.Error("GetHTTPClient should always return same client") + } +}