MCPcopy
hub / github.com/daptin/daptin / runTests

Function runTests

server_test.go:356–927  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

354}
355
356func 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 {

Callers 1

TestServerApisFunction · 0.70

Calls 6

makeFunction · 0.85
runOAuthProviderE2ETestsFunction · 0.85
FtpTestFunction · 0.85
ReadAllMethod · 0.80
GetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected