MCPcopy
hub / github.com/daptin/daptin / BenchmarkCreate

Function BenchmarkCreate

server_test.go:1251–1406  ·  view source on GitHub ↗

from fib_test.go

(m *testing.B)

Source from the content-addressed store, hash-verified

1249
1250// from fib_test.go
1251func BenchmarkCreate(m *testing.B) {
1252 // run the Fib function b.N times
1253
1254 m.StopTimer()
1255 const baseAddress = "http://localhost:6337"
1256 ensureServer()
1257
1258 requestClient := req.New()
1259
1260 resp, err := requestClient.Post(baseAddress+"/action/user_account/signup", req.BodyJSON(map[string]interface{}{
1261 "attributes": map[string]interface{}{
1262 "email": "test@gmail.com",
1263 "name": "name",
1264 "password": "tester123",
1265 "passwordConfirm": "tester123",
1266 },
1267 }))
1268
1269 if err != nil {
1270 panic(err)
1271 }
1272 var signUpResponse interface{}
1273
1274 resp.ToJSON(&signUpResponse)
1275
1276 if signUpResponse.([]interface{})[0].(map[string]interface{})["ResponseType"] != "client.notify" {
1277 m.Errorf("809 Unexpected response type from sign up - %v", signUpResponse)
1278 }
1279
1280 resp, err = requestClient.Post(baseAddress+"/action/user_account/signin", req.BodyJSON(map[string]interface{}{
1281 "attributes": map[string]interface{}{
1282 "email": "test@gmail.com",
1283 "password": "tester123",
1284 },
1285 }))
1286
1287 if err != nil {
1288 panic(err)
1289 }
1290
1291 var token string
1292 var signInResponse interface{}
1293
1294 resp.ToJSON(&signInResponse)
1295
1296 responseAttr := signInResponse.([]interface{})[0].(map[string]interface{})
1297 if responseAttr["ResponseType"] != "client.store.set" {
1298 m.Errorf("830 Unexpected response type from sign up - %v", responseAttr)
1299 }
1300
1301 token = responseAttr["Attributes"].(map[string]interface{})["value"].(string)
1302 authTokenHeader := req.Header{
1303 "Authorization": "Bearer " + token,
1304 }
1305
1306 createPayload := req.BodyJSON(map[string]interface{}{
1307 "data": map[string]interface{}{
1308 "type": "table10cols",

Callers

nothing calls this directly

Calls 6

ensureServerFunction · 0.85
makeFunction · 0.85
RunMethod · 0.80
StringMethod · 0.65
GetMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected