(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestClassifyList(t *testing.T) { |
| 114 | doc := loadDoc(t, ` |
| 115 | openapi: 3.0.0 |
| 116 | info: { title: Test, version: 1.0.0 } |
| 117 | paths: |
| 118 | /audit-logs: |
| 119 | get: |
| 120 | operationId: listAuditLogs |
| 121 | parameters: |
| 122 | - { name: actorId, in: query, schema: { type: string } } |
| 123 | responses: |
| 124 | '200': |
| 125 | description: ok |
| 126 | content: |
| 127 | application/json: |
| 128 | schema: |
| 129 | type: object |
| 130 | properties: |
| 131 | data: |
| 132 | type: array |
| 133 | items: { type: object } |
| 134 | `) |
| 135 | |
| 136 | spec := &Spec{Key: "test"} |
| 137 | ops, _ := classifyAll(spec, doc, SpecConfig{}) |
| 138 | if ops[0].Mode != OpModeList { |
| 139 | t.Errorf("mode = %v, want OpModeList", ops[0].Mode) |
| 140 | } |
| 141 | if !ops[0].IsArrayResponse { |
| 142 | t.Error("IsArrayResponse should be true for {data: [...]} shape") |
| 143 | } |
| 144 | if len(ops[0].ResultPath) != 1 || ops[0].ResultPath[0] != "data" { |
| 145 | t.Errorf("result_path = %v, want [data]", ops[0].ResultPath) |
| 146 | } |
| 147 | if len(ops[0].QueryParams) != 1 || ops[0].QueryParams[0].Name != "actorId" { |
| 148 | t.Errorf("query params = %+v", ops[0].QueryParams) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | func TestClassifySkipReasons(t *testing.T) { |
| 153 | cases := []struct { |
nothing calls this directly
no test coverage detected