getString is a test helper that retrieves a value as a string from the content at the given key. If the key does not exist in the content map or the value is not a string this will fail the test. The jsonObjectName parameter is a string used to name the content for more helpful fail messages.
(t *testing.T, jsonObjectName string, content map[string]interface{}, key string)
| 566 | // does not exist in the content map or the value is not a string this will fail the test. The jsonObjectName |
| 567 | // parameter is a string used to name the content for more helpful fail messages. |
| 568 | func getString(t *testing.T, jsonObjectName string, content map[string]interface{}, key string) string { |
| 569 | t.Helper() |
| 570 | |
| 571 | raw, ok := content[key] |
| 572 | if !ok { |
| 573 | t.Fatalf("\t%s %s[\"%s\"] field not present", failure, jsonObjectName, key) |
| 574 | } |
| 575 | |
| 576 | value, ok := raw.(string) |
| 577 | if !ok { |
| 578 | t.Fatalf("\t%s %s[\"%s\"] is not a string", failure, jsonObjectName, key) |
| 579 | } |
| 580 | |
| 581 | return value |
| 582 | } |
| 583 | |
| 584 | // getJSONObject is a test helper that retrieves a value as a map[string]interface{} from the content at the given key. |
| 585 | // If the key does not exist in the content map or the value is not a map[string]interface{} this will fail the test. |
no outgoing calls
no test coverage detected