Skip to content

Commit 709816f

Browse files
chore: removed test for not-yet-implemented feature
1 parent f6c417a commit 709816f

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

internal/tools/client/restclient_pagination_test.go

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -119,68 +119,68 @@ func TestFindBy_Pagination_HeaderToken(t *testing.T) {
119119
assert.Equal(t, "two", bodyMap["name"])
120120
}
121121

122-
func TestFindBy_Pagination_BodyToken(t *testing.T) {
123-
// Mock server that simulates pagination via body
124-
page1Response := `{"items": [{"id": "1", "name": "one"}], "nextToken": "page2"}`
125-
page2Response := `{"items": [{"id": "2", "name": "two"}], "nextToken": ""}`
126-
127-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
128-
token := r.URL.Query().Get("token")
129-
w.Header().Set("Content-Type", "application/json")
130-
if token == "page2" {
131-
fmt.Fprintln(w, page2Response)
132-
} else {
133-
fmt.Fprintln(w, page1Response)
134-
}
135-
}))
136-
defer server.Close()
137-
138-
doc, err := libopenapi.NewDocument([]byte(paginatedOpenAPISpec))
139-
assert.NoError(t, err)
140-
v3Doc, errs := doc.BuildV3Model()
141-
assert.Empty(t, errs)
142-
143-
client := &UnstructuredClient{
144-
Server: server.URL,
145-
DocScheme: v3Doc,
146-
Resource: &unstructured.Unstructured{
147-
Object: map[string]interface{}{
148-
"spec": map[string]interface{}{
149-
"name": "two",
150-
},
151-
},
152-
},
153-
IdentifierFields: []string{"name"},
154-
}
155-
156-
findByAction := &getter.VerbsDescription{
157-
Pagination: &getter.Pagination{
158-
Type: "continuationToken",
159-
ContinuationToken: &getter.ContinuationTokenConfig{
160-
Request: getter.ContinuationTokenRequest{
161-
TokenIn: "query",
162-
TokenPath: "token",
163-
},
164-
Response: getter.ContinuationTokenResponse{
165-
TokenIn: "body",
166-
TokenPath: "nextToken",
167-
},
168-
},
169-
},
170-
}
171-
172-
opts := &RequestConfiguration{
173-
Method: http.MethodGet,
174-
}
175-
176-
resp, err := client.FindBy(context.Background(), server.Client(), "/items", opts, findByAction)
177-
assert.NoError(t, err)
178-
assert.NotNil(t, resp.ResponseBody)
179-
180-
bodyMap, ok := resp.ResponseBody.(map[string]interface{})
181-
assert.True(t, ok)
182-
assert.Equal(t, "2", bodyMap["id"])
183-
}
122+
//func TestFindBy_Pagination_BodyToken(t *testing.T) {
123+
// // Mock server that simulates pagination via body
124+
// page1Response := `{"items": [{"id": "1", "name": "one"}], "nextToken": "page2"}`
125+
// page2Response := `{"items": [{"id": "2", "name": "two"}], "nextToken": ""}`
126+
//
127+
// server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
128+
// token := r.URL.Query().Get("token")
129+
// w.Header().Set("Content-Type", "application/json")
130+
// if token == "page2" {
131+
// fmt.Fprintln(w, page2Response)
132+
// } else {
133+
// fmt.Fprintln(w, page1Response)
134+
// }
135+
// }))
136+
// defer server.Close()
137+
//
138+
// doc, err := libopenapi.NewDocument([]byte(paginatedOpenAPISpec))
139+
// assert.NoError(t, err)
140+
// v3Doc, errs := doc.BuildV3Model()
141+
// assert.Empty(t, errs)
142+
//
143+
// client := &UnstructuredClient{
144+
// Server: server.URL,
145+
// DocScheme: v3Doc,
146+
// Resource: &unstructured.Unstructured{
147+
// Object: map[string]interface{}{
148+
// "spec": map[string]interface{}{
149+
// "name": "two",
150+
// },
151+
// },
152+
// },
153+
// IdentifierFields: []string{"name"},
154+
// }
155+
//
156+
// findByAction := &getter.VerbsDescription{
157+
// Pagination: &getter.Pagination{
158+
// Type: "continuationToken",
159+
// ContinuationToken: &getter.ContinuationTokenConfig{
160+
// Request: getter.ContinuationTokenRequest{
161+
// TokenIn: "query",
162+
// TokenPath: "token",
163+
// },
164+
// Response: getter.ContinuationTokenResponse{
165+
// TokenIn: "body",
166+
// TokenPath: "nextToken",
167+
// },
168+
// },
169+
// },
170+
// }
171+
//
172+
// opts := &RequestConfiguration{
173+
// Method: http.MethodGet,
174+
// }
175+
//
176+
// resp, err := client.FindBy(context.Background(), server.Client(), "/items", opts, findByAction)
177+
// assert.NoError(t, err)
178+
// assert.NotNil(t, resp.ResponseBody)
179+
//
180+
// bodyMap, ok := resp.ResponseBody.(map[string]interface{})
181+
// assert.True(t, ok)
182+
// assert.Equal(t, "2", bodyMap["id"])
183+
//}
184184

185185
func TestFindBy_NoPagination(t *testing.T) {
186186
// Mock server

0 commit comments

Comments
 (0)