Skip to content

Commit

Permalink
carbonapi: fix some linter warnings and make test verbose for easy ci…
Browse files Browse the repository at this point in the history
… debugging
  • Loading branch information
bom-d-van committed Nov 5, 2021
1 parent 1dd0b2d commit 477853a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ lint:
check: test vet

test:
$(PKGCONF) $(GO) test ./... -race -coverprofile=coverage.txt -covermode=atomic
$(PKGCONF) $(GO) test ./... -v -race -coverprofile=coverage.txt -covermode=atomic

clean:
rm -f carbonapi carbonzipper
Expand Down
4 changes: 2 additions & 2 deletions app/carbonapi/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,9 @@ func (app *App) renderHandlerProcessForm(r *http.Request, accessLogDetails *carb
if errFrom != nil || errUntil != nil {
errFmt := "%s, invalid parameter %s=%s"
if errFrom != nil {
return res, errors.New(fmt.Sprintf(errFmt, errFrom.Error(), "from", res.from))
return res, fmt.Errorf(errFmt, errFrom.Error(), "from", res.from)
}
return res, errors.New(fmt.Sprintf(errFmt, errUntil.Error(), "until", res.until))
return res, fmt.Errorf(errFmt, errUntil.Error(), "until", res.until)
}

return res, nil
Expand Down
6 changes: 4 additions & 2 deletions date/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
)

func TestDateParamToEpoch(t *testing.T) {

defaultTimeZone := time.Local
timeNow = func() time.Time {
//16 Aug 1994 15:30
return time.Date(1994, time.August, 16, 15, 30, 0, 100, defaultTimeZone)
}

t.Logf("defaultTimeZone = %+v\n", defaultTimeZone)

const shortForm = "15:04 2006-Jan-02"
const defaultTsStr = "17:30 2019-Apr-25"

Expand All @@ -40,7 +41,8 @@ func TestDateParamToEpoch(t *testing.T) {
{"12:mm 19940812", "00:00 1994-Aug-12", true},
{"today", "00:00 1994-Aug-16", false},
{"yesterday", "00:00 1994-Aug-15", false},
{"1556201160", "16:06 2019-Apr-25", false},
// {"1556201160", "16:06 2019-Apr-25", false},
{"1556201160", time.Unix(1556201160, 0).Format(shortForm), false},
{"", defaultTsStr, false},
{"-something", defaultTsStr, true},
{"17:04 19940812 1001", defaultTsStr, true},
Expand Down

0 comments on commit 477853a

Please sign in to comment.