Skip to content

Commit

Permalink
Add some more heatmap decoder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Jun 28, 2021
1 parent f7a72f2 commit 2787dcd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions decoder/heatmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package decoder
import (
"testing"

"github.com/K-Phoen/grabana/heatmap/axis"

"github.com/stretchr/testify/require"
)

Expand All @@ -20,12 +22,33 @@ func TestHeatmapCanBeDecoded(t *testing.T) {
HighlightCards: true,
Targets: nil,
ReverseYBuckets: true,
YAxis: &HeatmapYAxis{
Unit: "none",
},
}

_, err := panel.toOption()
req.NoError(err)
}

func TestHeatmapYAxisCanBeDecoded(t *testing.T) {
req := require.New(t)

decimals := 2
min := float64(1)
max := float64(3)
axisInput := HeatmapYAxis{
Decimals: &decimals,
Unit: "none",
Max: &min,
Min: &max,
}

decoded := axis.New(axisInput.toOptions()...).Builder
req.Equal("none", decoded.Format)
req.Equal(2, *decoded.Decimals)
}

func TestHeatmapCanNotBeDecodedIfDataFormatIsInvalid(t *testing.T) {
req := require.New(t)

Expand Down

0 comments on commit 2787dcd

Please sign in to comment.