(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func 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 | |
| 95 | func TestDryRunAPI_MultipleCalls(t *testing.T) { |
| 96 | dr := NewDryRunAPI(). |
nothing calls this directly
no test coverage detected