(t *testing.T)
| 252 | } |
| 253 | |
| 254 | func Test_extractStatus(t *testing.T) { |
| 255 | type args struct { |
| 256 | blob []byte |
| 257 | } |
| 258 | tests := []struct { |
| 259 | name string |
| 260 | args args |
| 261 | want map[string]string |
| 262 | want1 errors.Error |
| 263 | }{ |
| 264 | { |
| 265 | "non-empty array", |
| 266 | args{ |
| 267 | blob: []byte(`{"data":[{"id":1,"name":"已完成","is_last_step":true},{"id":2,"name":"进行中"}],"status":1,"message":"success"}`), |
| 268 | }, |
| 269 | nil, |
| 270 | nil, |
| 271 | }, |
| 272 | { |
| 273 | "empty array", |
| 274 | args{ |
| 275 | blob: []byte(`{"status":1,"data":[],"info":"success"}`), |
| 276 | }, |
| 277 | nil, |
| 278 | nil, |
| 279 | }, |
| 280 | { |
| 281 | "object", |
| 282 | args{ |
| 283 | blob: []byte(`{"status":1,"data":{"new":"新建","in_progress":"开发处理"},"info":"success"}`), |
| 284 | }, |
| 285 | map[string]string{"new": "新建", "in_progress": "开发处理"}, |
| 286 | nil, |
| 287 | }, |
| 288 | } |
| 289 | for _, tt := range tests { |
| 290 | t.Run(tt.name, func(t *testing.T) { |
| 291 | got, got1 := extractStatus(tt.args.blob) |
| 292 | assert.Equalf(t, tt.want, got, "extractStatus(%v)", tt.args.blob) |
| 293 | assert.Equalf(t, tt.want1, got1, "extractStatus(%v)", tt.args.blob) |
| 294 | }) |
| 295 | } |
| 296 | } |
nothing calls this directly
no test coverage detected