chore: fix tests
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -19,26 +18,24 @@ func (s Service) createInvoice(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
if err != nil {
|
||||
s.sendErrf(w, http.StatusBadRequest, "cannot read body: %v", err)
|
||||
s.sendErr(w, http.StatusBadRequest, "cannot read body")
|
||||
return
|
||||
}
|
||||
|
||||
repos, err := req.GetRepos()
|
||||
if err != nil {
|
||||
s.sendErr(w, 500, err.Error())
|
||||
s.sendErr(w, http.StatusInternalServerError, "cannot get repos")
|
||||
return
|
||||
}
|
||||
|
||||
invoice, report, err := s.invoice.Generate(req.Creditor, req.Debtor, time.Duration(req.DurationThreshold), req.HourlyRate, repos)
|
||||
if err != nil {
|
||||
log.Println("error while processing invoice:", err)
|
||||
fmt.Fprint(w, "internal server error")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
s.sendErr(w, http.StatusInternalServerError, "internal server error")
|
||||
return
|
||||
}
|
||||
// if no time has to be billed aka if bill for 0 CHF
|
||||
if report.Total() <= time.Duration(0) {
|
||||
s.sendErr(w, http.StatusNotFound, "no suitable issues to be billed")
|
||||
s.sendErrf(w, http.StatusNotFound, "no suitable issues to be billed")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user