MCPcopy Index your code
hub / github.com/dnote/dnote / TestSendNotes_isBehind

Function TestSendNotes_isBehind

pkg/cli/cmd/sync/sync_test.go:2494–2697  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2492}
2493
2494func TestSendNotes_isBehind(t *testing.T) {
2495 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2496 if r.URL.String() == "/v3/notes" && r.Method == "POST" {
2497 var payload client.CreateBookPayload
2498
2499 err := json.NewDecoder(r.Body).Decode(&payload)
2500 if err != nil {
2501 t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
2502 return
2503 }
2504
2505 resp := client.CreateNoteResp{
2506 Result: client.RespNote{
2507 USN: 11,
2508 },
2509 }
2510
2511 w.Header().Set("Content-Type", "application/json")
2512 if err := json.NewEncoder(w).Encode(resp); err != nil {
2513 http.Error(w, err.Error(), http.StatusInternalServerError)
2514 return
2515 }
2516 return
2517 }
2518
2519 p := strings.Split(r.URL.Path, "/")
2520 if len(p) == 4 && p[0] == "" && p[1] == "v3" && p[2] == "notes" {
2521 if r.Method == "PATCH" {
2522 resp := client.UpdateNoteResp{
2523 Result: client.RespNote{
2524 USN: 11,
2525 },
2526 }
2527
2528 w.Header().Set("Content-Type", "application/json")
2529 if err := json.NewEncoder(w).Encode(resp); err != nil {
2530 http.Error(w, err.Error(), http.StatusInternalServerError)
2531 return
2532 }
2533 return
2534 } else if r.Method == "DELETE" {
2535 resp := client.DeleteNoteResp{
2536 Result: client.RespNote{
2537 USN: 11,
2538 },
2539 }
2540
2541 w.Header().Set("Content-Type", "application/json")
2542 if err := json.NewEncoder(w).Encode(resp); err != nil {
2543 http.Error(w, err.Error(), http.StatusInternalServerError)
2544 return
2545 }
2546 return
2547 }
2548 }
2549
2550 t.Fatalf("unrecognized endpoint reached Method: %s Path: %s", r.Method, r.URL.Path)
2551 }))

Callers

nothing calls this directly

Calls 10

InitTestCtxFunction · 0.92
LoginFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
sendNotesFunction · 0.85
CloseMethod · 0.65
BeginMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected