(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func TestClassifyRowJoinUpgrade(t *testing.T) { |
| 74 | doc := loadDoc(t, ` |
| 75 | openapi: 3.0.0 |
| 76 | info: { title: Test, version: 1.0.0 } |
| 77 | paths: |
| 78 | /users/{userId}: |
| 79 | get: |
| 80 | operationId: getUserById |
| 81 | parameters: |
| 82 | - { name: userId, in: path, required: true, schema: { type: string } } |
| 83 | responses: |
| 84 | '200': |
| 85 | description: ok |
| 86 | content: { application/json: { schema: { type: object } } } |
| 87 | `) |
| 88 | |
| 89 | cfg := SpecConfig{ |
| 90 | Joins: map[string]JoinConfig{ |
| 91 | "getUserById": { |
| 92 | ParentTable: "users", |
| 93 | ParentColumn: "email", |
| 94 | Param: "userId", |
| 95 | ExposeAs: "is_profile", |
| 96 | }, |
| 97 | }, |
| 98 | } |
| 99 | |
| 100 | spec := &Spec{Key: "test"} |
| 101 | ops, _ := classifyAll(spec, doc, cfg) |
| 102 | if ops[0].Mode != OpModeRowJoin { |
| 103 | t.Errorf("mode = %v, want OpModeRowJoin", ops[0].Mode) |
| 104 | } |
| 105 | if ops[0].Join == nil || ops[0].Join.ParentTable != "users" { |
| 106 | t.Errorf("join not wired correctly: %+v", ops[0].Join) |
| 107 | } |
| 108 | if ops[0].ExposeAs != "is_profile" { |
| 109 | t.Errorf("expose_as override not applied: %q", ops[0].ExposeAs) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | func TestClassifyList(t *testing.T) { |
| 114 | doc := loadDoc(t, ` |
nothing calls this directly
no test coverage detected