MCPcopy Create free account
hub / github.com/dropbox/dbxcli / assertGoldenJSONEqual

Function assertGoldenJSONEqual

cmd/json_contract_test.go:622–645  ·  view source on GitHub ↗
(t *testing.T, command string, fixture json.RawMessage, actual any)

Source from the content-addressed store, hash-verified

620}
621
622func assertGoldenJSONEqual(t *testing.T, command string, fixture json.RawMessage, actual any) {
623 t.Helper()
624
625 actualJSON, err := json.Marshal(actual)
626 if err != nil {
627 t.Fatalf("marshal JSON example for %q: %v", command, err)
628 }
629
630 var got any
631 if err := json.Unmarshal(fixture, &got); err != nil {
632 t.Fatalf("decode golden output for %q: %v", command, err)
633 }
634 var want any
635 if err := json.Unmarshal(actualJSON, &want); err != nil {
636 t.Fatalf("decode generated output for %q: %v", command, err)
637 }
638 if reflect.DeepEqual(got, want) {
639 return
640 }
641
642 gotJSON, _ := json.MarshalIndent(got, "", " ")
643 wantJSON, _ := json.MarshalIndent(want, "", " ")
644 t.Errorf("golden output for %q = %s, want %s", command, gotJSON, wantJSON)
645}
646
647func assertGoldenSuccessOutputStatuses(t *testing.T, command string, fixture json.RawMessage) {
648 t.Helper()

Calls

no outgoing calls

Tested by

no test coverage detected