From 7f1e818daa762eddb7ac67599fd738386aa62ae6 Mon Sep 17 00:00:00 2001 From: Thomas Rooney Date: Fri, 4 Oct 2024 15:17:23 +0100 Subject: [PATCH] chore: add test --- index/rolodex_test_data/components.yaml | 7 +++++++ index/rolodex_test_data/paths/paths.yaml | 2 ++ index/search_rolodex_test.go | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/index/rolodex_test_data/components.yaml b/index/rolodex_test_data/components.yaml index 8d521eef..9982cbcd 100644 --- a/index/rolodex_test_data/components.yaml +++ b/index/rolodex_test_data/components.yaml @@ -3,6 +3,13 @@ info: title: Rolodex Test Data version: 1.0.0 components: + parameters: + SomeParam: + name: someParam + in: query + description: A parameter that does nothing. Ding a ling! + schema: + type: string schemas: Ding: type: object diff --git a/index/rolodex_test_data/paths/paths.yaml b/index/rolodex_test_data/paths/paths.yaml index db3ef878..f3b2b59c 100644 --- a/index/rolodex_test_data/paths/paths.yaml +++ b/index/rolodex_test_data/paths/paths.yaml @@ -1,5 +1,7 @@ /some/path: get: + parameters: + - $ref: '../components.yaml#/components/parameters/SomeParam' responses: '200': description: OK diff --git a/index/search_rolodex_test.go b/index/search_rolodex_test.go index 2bac159a..f7d7898a 100644 --- a/index/search_rolodex_test.go +++ b/index/search_rolodex_test.go @@ -132,9 +132,9 @@ func TestSpecIndex_TestPathsAsRefWithFiles(t *testing.T) { yml := `paths: /test: - $ref: 'rolodex_test_data/paths/paths.yaml' + $ref: 'rolodex_test_data/paths/paths.yaml#/~1some~1path' /test-2: - $ref: './rolodex_test_data/paths/paths.yaml' + $ref: './rolodex_test_data/paths/paths.yaml#/~1some~1path' ` baseDir := "." @@ -166,4 +166,15 @@ func TestSpecIndex_TestPathsAsRefWithFiles(t *testing.T) { assert.Len(t, rolo.indexes, 2) assert.Len(t, rolo.GetCaughtErrors(), 0) + params := rolo.rootIndex.GetAllParametersFromOperations() + assert.Len(t, params, 2) + lookupPath, ok := params["/test"] + assert.True(t, ok) + lookupOperation, ok := lookupPath["get"] + assert.True(t, ok) + assert.Len(t, lookupOperation, 1) + lookupRef, ok := lookupOperation["../components.yaml#/components/parameters/SomeParam"] + assert.True(t, ok) + assert.Len(t, lookupRef, 1) + assert.Equal(t, lookupRef[0].Name, "SomeParam") }