(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func runTests(t *testing.T) error { |
| 357 | |
| 358 | const baseAddress = "http://localhost:6337" |
| 359 | |
| 360 | requestClient := req.New() |
| 361 | requestClient.SetTimeout(900 * time.Second) |
| 362 | |
| 363 | responseMap := make(map[string]interface{}) |
| 364 | |
| 365 | resp, err := requestClient.Get(baseAddress+"/api/world", req.QueryParam{ |
| 366 | "page[size]": 100, |
| 367 | "page[number]": 1, |
| 368 | "sort": "", |
| 369 | }) |
| 370 | if err != nil { |
| 371 | log.Printf("Failed to get %s %s", "world", err) |
| 372 | return fmt.Errorf("failed to get world %v", err) |
| 373 | } |
| 374 | |
| 375 | responseMap = make(map[string]interface{}) |
| 376 | |
| 377 | resp, err = requestClient.Get(baseAddress+"/api/world", req.QueryParam{ |
| 378 | "page[size]": 100, |
| 379 | "page[number]": 1, |
| 380 | "sort": "-reference_id", |
| 381 | }) |
| 382 | if err != nil { |
| 383 | log.Printf("Failed to get %s %s", "world", err) |
| 384 | return fmt.Errorf("340 failed to get world %v", err) |
| 385 | } |
| 386 | |
| 387 | resp.ToJSON(&responseMap) |
| 388 | |
| 389 | tableNameToIdMap := map[string]string{} |
| 390 | |
| 391 | data := responseMap["data"].([]interface{}) |
| 392 | for _, row := range data { |
| 393 | rowm := row.(map[string]interface{}) |
| 394 | attributes := rowm["attributes"].(map[string]interface{}) |
| 395 | tableNameToIdMap[attributes["table_name"].(string)] = rowm["id"].(string) |
| 396 | } |
| 397 | firstRow := data[0].(map[string]interface{}) |
| 398 | |
| 399 | if firstRow["type"] != "world" { |
| 400 | t.Errorf("world type mismatch") |
| 401 | } |
| 402 | |
| 403 | resp, err = requestClient.Get(baseAddress + "/actions") |
| 404 | |
| 405 | if err != nil { |
| 406 | return fmt.Errorf("362 failed to get actions %v", err) |
| 407 | } |
| 408 | |
| 409 | actionMap := make(map[string]interface{}) |
| 410 | resp.ToJSON(&actionMap) |
| 411 | |
| 412 | signInAction, ok := actionMap["user:signin"].(map[string]interface{}) |
| 413 | if !ok { |
no test coverage detected