From 7ea306b7f46ee1d718201ca792c82f12b23ec805 Mon Sep 17 00:00:00 2001 From: vicanso Date: Sat, 19 Feb 2022 09:26:11 +0800 Subject: [PATCH] test: fix test --- echarts.go | 2 +- echarts_test.go | 12 ++++++++---- go.mod | 2 +- line_chart_test.go | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/echarts.go b/echarts.go index dc2e761..db50e5d 100644 --- a/echarts.go +++ b/echarts.go @@ -76,7 +76,7 @@ type EChartsSeriesData struct { } type _EChartsSeriesData EChartsSeriesData -var numericRep = regexp.MustCompile("^[-+]?[0-9]+(?:\\.[0-9]+)?$") +var numericRep = regexp.MustCompile(`^[-+]?[0-9]+(?:\\.[0-9]+)?$`) func (es *EChartsSeriesData) UnmarshalJSON(data []byte) error { data = bytes.TrimSpace(data) diff --git a/echarts_test.go b/echarts_test.go index d80ecbb..67fabf6 100644 --- a/echarts_test.go +++ b/echarts_test.go @@ -165,7 +165,8 @@ func TestEChartsPadding(t *testing.T) { ep := EChartsPadding{} - ep.UnmarshalJSON([]byte(`10`)) + err := ep.UnmarshalJSON([]byte(`10`)) + assert.Nil(err) assert.Equal(EChartsPadding{ Box: chart.Box{ Top: 10, @@ -176,7 +177,8 @@ func TestEChartsPadding(t *testing.T) { }, ep) ep = EChartsPadding{} - ep.UnmarshalJSON([]byte(`[10, 20]`)) + err = ep.UnmarshalJSON([]byte(`[10, 20]`)) + assert.Nil(err) assert.Equal(EChartsPadding{ Box: chart.Box{ Top: 10, @@ -187,7 +189,8 @@ func TestEChartsPadding(t *testing.T) { }, ep) ep = EChartsPadding{} - ep.UnmarshalJSON([]byte(`[10, 20, 30]`)) + err = ep.UnmarshalJSON([]byte(`[10, 20, 30]`)) + assert.Nil(err) assert.Equal(EChartsPadding{ Box: chart.Box{ Top: 10, @@ -198,7 +201,8 @@ func TestEChartsPadding(t *testing.T) { }, ep) ep = EChartsPadding{} - ep.UnmarshalJSON([]byte(`[10, 20, 30, 40]`)) + err = ep.UnmarshalJSON([]byte(`[10, 20, 30, 40]`)) + assert.Nil(err) assert.Equal(EChartsPadding{ Box: chart.Box{ Top: 10, diff --git a/go.mod b/go.mod index b21ce18..5f58f2d 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.17 require ( github.com/dustin/go-humanize v1.0.0 + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/stretchr/testify v1.7.0 github.com/wcharczuk/go-chart/v2 v2.1.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/line_chart_test.go b/line_chart_test.go index 62d0a40..9f5d9af 100644 --- a/line_chart_test.go +++ b/line_chart_test.go @@ -60,7 +60,7 @@ func TestLineChartRender(t *testing.T) { d: d, } f, _ := chart.GetDefaultFont() - lineChartRender(lineChartOption{ + _, err = lineChartRender(lineChartOption{ Font: f, SeriesList: SeriesList{ { @@ -90,6 +90,7 @@ func TestLineChartRender(t *testing.T) { }), }, }, &result) + assert.Nil(err) data, err := d.Bytes() assert.Nil(err) assert.Equal("\\n56.66206090", string(data))