Skip to content

Commit

Permalink
Add chart to renderer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
obukhov committed Aug 13, 2021
1 parent de30e16 commit a530427
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderer/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package renderer
import (
"code.cloudfoundry.org/bytefmt"
"encoding/json"
"errors"
"github.com/hetiansu5/urlquery"
"github.com/obukhov/redis-inventory/src/server"
"github.com/obukhov/redis-inventory/src/trie"
Expand All @@ -19,6 +20,10 @@ func NewChartRendererParams(paramsSerialized string) (ChartRendererParams, error
return params, err
}

if params.Port <= 0 {
return params, errors.New("port cannot be negative")
}

return params, nil
}

Expand Down
9 changes: 9 additions & 0 deletions src/renderer/renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func (suite *RendererTestSuite) TestNewRender() {
"",
JSONRenderer{},
},
{
"chart",
"",
ChartRenderer{},
},
} {
suite.Run(t.outputParams, func() {
renderer, err := NewRenderer(t.output, t.outputParams, zerolog.Nop())
Expand All @@ -49,6 +54,10 @@ func (suite *RendererTestSuite) TestNewRenderWithError() {
"json",
"padSpaces=asd",
},
{
"chart",
"port=-1",
},
} {
suite.Run(t.outputParams, func() {
renderer, err := NewRenderer(t.output, t.outputParams, zerolog.Nop())
Expand Down

0 comments on commit a530427

Please sign in to comment.