test: add test for charts

This commit is contained in:
vicanso 2022-06-21 20:18:27 +08:00
parent 212a51083f
commit 6695a3a062
6 changed files with 827 additions and 61 deletions

View file

@ -69,9 +69,9 @@ type ChartOption struct {
// OptionFunc option function // OptionFunc option function
type OptionFunc func(opt *ChartOption) type OptionFunc func(opt *ChartOption)
// PNGTypeOption set png type of chart's output // SVGTypeOption set svg type of chart's output
func PNGTypeOption() OptionFunc { func SVGTypeOption() OptionFunc {
return TypeOptionFunc(ChartOutputPNG) return TypeOptionFunc(ChartOutputSVG)
} }
// TypeOptionFunc set type of chart's output // TypeOptionFunc set type of chart's output

451
chart_option_test.go Normal file

File diff suppressed because one or more lines are too long

View file

@ -60,9 +60,9 @@ type EChartStyle struct {
Color string `json:"color"` Color string `json:"color"`
} }
func (es *EChartStyle) ToStyle() chart.Style { func (es *EChartStyle) ToStyle() Style {
color := parseColor(es.Color) color := parseColor(es.Color)
return chart.Style{ return Style{
FillColor: color, FillColor: color,
FontColor: color, FontColor: color,
StrokeColor: color, StrokeColor: color,

File diff suppressed because one or more lines are too long

View file

@ -23,7 +23,6 @@
package charts package charts
import ( import (
"fmt"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -98,7 +97,6 @@ func TestNewLegend(t *testing.T) {
assert.Nil(err) assert.Nil(err)
data, err := tt.render(p) data, err := tt.render(p)
assert.Nil(err) assert.Nil(err)
fmt.Println(string(data))
assert.Equal(tt.result, string(data)) assert.Equal(tt.result, string(data))
} }
} }

View file

@ -23,7 +23,6 @@
package charts package charts
import ( import (
"fmt"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -103,7 +102,6 @@ func TestRadarChart(t *testing.T) {
Bottom: 20, Bottom: 20,
}))) })))
assert.Nil(err) assert.Nil(err)
fmt.Println(string(data))
assert.Equal(tt.result, string(data)) assert.Equal(tt.result, string(data))
} }
} }