File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 44 "os"
55 "path/filepath"
66 "reflect"
7+ "runtime"
78 "slices"
89 "strings"
910 "testing"
@@ -325,11 +326,12 @@ func TestLeafProperties(t *testing.T) {
325326// to files relative to this location will remain valid even if the repository structure
326327// changes or the source is downloaded without git metadata.
327328func TestMagicianLocation (t * testing.T ) {
328- // Get the current working directory of the test
329- pwd , err := os . Getwd ( )
330- if err != nil {
331- t .Fatalf ("Failed to get working directory: %v" , err )
329+ // Get the path where this test file is located
330+ _ , testFilePath , _ , ok := runtime . Caller ( 0 )
331+ if ! ok {
332+ t .Fatal ("Failed to get current test file path" )
332333 }
334+ pwd := filepath .Dir (testFilePath )
333335
334336 // Walk up directories until we either:
335337 // 1. Find the mmv1 directory
Original file line number Diff line number Diff line change 11package openapi_generate
22
33import (
4- "context"
5- "github.com/getkin/kin-openapi/openapi3"
4+ _ "embed"
65 "testing"
6+
7+ "github.com/getkin/kin-openapi/openapi3"
78)
89
10+ //go:embed test_data/test_api.yaml
11+ var testData []byte
12+
913func TestMapType (t * testing.T ) {
1014 _ = NewOpenapiParser ("/fake" , "/fake" )
11- ctx := context . Background ()
15+ ctx := t . Context ()
1216 loader := & openapi3.Loader {Context : ctx , IsExternalRefsAllowed : true }
13- doc , _ := loader .LoadFromFile ( "./test_data/test_api.yaml" )
17+ doc , _ := loader .LoadFromData ( testData )
1418 _ = doc .Validate (ctx )
1519
1620 petSchema := doc .Paths .Map ()["/pets" ].Post .Parameters [0 ].Value .Schema
You can’t perform that action at this time.
0 commit comments