@@ -11,14 +11,14 @@ func TestRenderChart(t *testing.T) {
1111
1212 tests := []struct {
1313 name string
14- input RenderChartInput
14+ input ChartData
1515 wantErr bool
1616 errContains string
1717 validate func (* testing.T , * ChartData )
1818 }{
1919 {
2020 name : "valid chart with all fields" ,
21- input : RenderChartInput {
21+ input : ChartData {
2222 ChartType : "line" ,
2323 Title : "CPU Usage" ,
2424 Environment : "dev" ,
@@ -54,7 +54,7 @@ func TestRenderChart(t *testing.T) {
5454 },
5555 {
5656 name : "valid chart with required fields only" ,
57- input : RenderChartInput {
57+ input : ChartData {
5858 ChartType : "line" ,
5959 Title : "Memory Usage" ,
6060 Environment : "prod" ,
@@ -78,49 +78,49 @@ func TestRenderChart(t *testing.T) {
7878 },
7979 {
8080 name : "missing chart_type" ,
81- input : RenderChartInput {Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
81+ input : ChartData {Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
8282 wantErr : true ,
8383 errContains : "chart_type is required" ,
8484 },
8585 {
8686 name : "empty chart_type" ,
87- input : RenderChartInput {ChartType : "" , Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
87+ input : ChartData {ChartType : "" , Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
8888 wantErr : true ,
8989 errContains : "chart_type is required" ,
9090 },
9191 {
9292 name : "unsupported chart_type" ,
93- input : RenderChartInput {ChartType : "bar" , Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
93+ input : ChartData {ChartType : "bar" , Title : "CPU Usage" , Environment : "dev" , Query : "some_query" },
9494 wantErr : true ,
9595 errContains : "unsupported chart_type" ,
9696 },
9797 {
9898 name : "missing title" ,
99- input : RenderChartInput {ChartType : "line" , Environment : "dev" , Query : "some_query" },
99+ input : ChartData {ChartType : "line" , Environment : "dev" , Query : "some_query" },
100100 wantErr : true ,
101101 errContains : "title is required" ,
102102 },
103103 {
104104 name : "missing environment" ,
105- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Query : "some_query" },
105+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Query : "some_query" },
106106 wantErr : true ,
107107 errContains : "environment is required" ,
108108 },
109109 {
110110 name : "missing query" ,
111- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" },
111+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" },
112112 wantErr : true ,
113113 errContains : "query is required" ,
114114 },
115115 {
116116 name : "invalid interval" ,
117- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "2h" },
117+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "2h" },
118118 wantErr : true ,
119119 errContains : "invalid interval" ,
120120 },
121121 {
122122 name : "valid interval 6h" ,
123- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "6h" },
123+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "6h" },
124124 validate : func (t * testing.T , c * ChartData ) {
125125 if c .Interval != "6h" {
126126 t .Errorf ("expected interval '6h', got %q" , c .Interval )
@@ -129,7 +129,7 @@ func TestRenderChart(t *testing.T) {
129129 },
130130 {
131131 name : "valid interval 1d" ,
132- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "1d" },
132+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "1d" },
133133 validate : func (t * testing.T , c * ChartData ) {
134134 if c .Interval != "1d" {
135135 t .Errorf ("expected interval '1d', got %q" , c .Interval )
@@ -138,7 +138,7 @@ func TestRenderChart(t *testing.T) {
138138 },
139139 {
140140 name : "valid interval 7d" ,
141- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "7d" },
141+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "7d" },
142142 validate : func (t * testing.T , c * ChartData ) {
143143 if c .Interval != "7d" {
144144 t .Errorf ("expected interval '7d', got %q" , c .Interval )
@@ -147,7 +147,7 @@ func TestRenderChart(t *testing.T) {
147147 },
148148 {
149149 name : "valid interval 30d" ,
150- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "30d" },
150+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , Interval : "30d" },
151151 validate : func (t * testing.T , c * ChartData ) {
152152 if c .Interval != "30d" {
153153 t .Errorf ("expected interval '30d', got %q" , c .Interval )
@@ -156,13 +156,13 @@ func TestRenderChart(t *testing.T) {
156156 },
157157 {
158158 name : "invalid y_format" ,
159- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "invalid" },
159+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "invalid" },
160160 wantErr : true ,
161161 errContains : "invalid y_format" ,
162162 },
163163 {
164164 name : "valid y_format number" ,
165- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "number" },
165+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "number" },
166166 validate : func (t * testing.T , c * ChartData ) {
167167 if c .YFormat != "number" {
168168 t .Errorf ("expected y_format 'number', got %q" , c .YFormat )
@@ -171,7 +171,7 @@ func TestRenderChart(t *testing.T) {
171171 },
172172 {
173173 name : "valid y_format percentage" ,
174- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "percentage" },
174+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "percentage" },
175175 validate : func (t * testing.T , c * ChartData ) {
176176 if c .YFormat != "percentage" {
177177 t .Errorf ("expected y_format 'percentage', got %q" , c .YFormat )
@@ -180,7 +180,7 @@ func TestRenderChart(t *testing.T) {
180180 },
181181 {
182182 name : "valid y_format bytes" ,
183- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "bytes" },
183+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "bytes" },
184184 validate : func (t * testing.T , c * ChartData ) {
185185 if c .YFormat != "bytes" {
186186 t .Errorf ("expected y_format 'bytes', got %q" , c .YFormat )
@@ -189,7 +189,7 @@ func TestRenderChart(t *testing.T) {
189189 },
190190 {
191191 name : "valid y_format cpu_cores" ,
192- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "cpu_cores" },
192+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "cpu_cores" },
193193 validate : func (t * testing.T , c * ChartData ) {
194194 if c .YFormat != "cpu_cores" {
195195 t .Errorf ("expected y_format 'cpu_cores', got %q" , c .YFormat )
@@ -198,7 +198,7 @@ func TestRenderChart(t *testing.T) {
198198 },
199199 {
200200 name : "valid y_format duration" ,
201- input : RenderChartInput {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "duration" },
201+ input : ChartData {ChartType : "line" , Title : "CPU Usage" , Environment : "dev" , Query : "q" , YFormat : "duration" },
202202 validate : func (t * testing.T , c * ChartData ) {
203203 if c .YFormat != "duration" {
204204 t .Errorf ("expected y_format 'duration', got %q" , c .YFormat )
0 commit comments