MCPcopy Index your code
hub / github.com/gopherdata/gophernotes / getJSONObject

Function getJSONObject

kernel_test.go:587–601  ·  view source on GitHub ↗

getJSONObject is a test helper that retrieves a value as a map[string]interface{} from the content at the given key. If the key does not exist in the content map or the value is not a map[string]interface{} this will fail the test. The jsonObjectName parameter is a string used to name the content f

(t *testing.T, jsonObjectName string, content map[string]interface{}, key string)

Source from the content-addressed store, hash-verified

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.
586// The jsonObjectName parameter is a string used to name the content for more helpful fail messages.
587func getJSONObject(t *testing.T, jsonObjectName string, content map[string]interface{}, key string) map[string]interface{} {
588 t.Helper()
589
590 raw, ok := content[key]
591 if !ok {
592 t.Fatalf("\t%s %s[\"%s\"] field not present", failure, jsonObjectName, key)
593 }
594
595 value, ok := raw.(map[string]interface{})
596 if !ok {
597 t.Fatalf("\t%s %s[\"%s\"] is not a JSON object", failure, jsonObjectName, key)
598 }
599
600 return value
601}
602
603// testOutputStream is a test helper that collects "stream" messages upon executing the codeIn.
604func testOutputStream(t *testing.T, codeIn string) ([]string, []string) {

Callers 1

testEvaluateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected