MCPcopy
hub / github.com/larksuite/cli / TestDryRunAPI_MarshalJSON

Function TestDryRunAPI_MarshalJSON

internal/cmdutil/dryrun_test.go:69–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestDryRunAPI_MarshalJSON(t *testing.T) {
70 dr := NewDryRunAPI().
71 Desc("test api").
72 GET("/open-apis/test").
73 Set("as", "user")
74
75 data, err := json.Marshal(dr)
76 if err != nil {
77 t.Fatalf("MarshalJSON failed: %v", err)
78 }
79 var m map[string]interface{}
80 if err := json.Unmarshal(data, &m); err != nil {
81 t.Fatalf("unmarshal failed: %v", err)
82 }
83 if m["description"] != "test api" {
84 t.Errorf("expected description, got: %v", m["description"])
85 }
86 if m["as"] != "user" {
87 t.Errorf("expected as=user, got: %v", m["as"])
88 }
89 api, ok := m["api"].([]interface{})
90 if !ok || len(api) != 1 {
91 t.Errorf("expected 1 api call, got: %v", m["api"])
92 }
93}
94
95func TestDryRunAPI_MultipleCalls(t *testing.T) {
96 dr := NewDryRunAPI().

Callers

nothing calls this directly

Calls 4

NewDryRunAPIFunction · 0.85
GETMethod · 0.80
DescMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected