github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/cmd/swagger/commands/expand_test.go (about) 1 package commands 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 flags "github.com/jessevdk/go-flags" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 // Commands requires at least one arg 13 func TestCmd_Expand(t *testing.T) { 14 v := &ExpandSpec{} 15 testRequireParam(t, v) 16 } 17 18 func TestCmd_Expand_NoError(t *testing.T) { 19 specDoc := filepath.Join(fixtureBase, "bugs", "1536", "fixture-1536.yaml") 20 outDir, output := getOutput(t, specDoc, "flatten", "fixture-1536-flat-expand.json") 21 defer os.RemoveAll(outDir) 22 v := &ExpandSpec{ 23 Format: "json", 24 Compact: false, 25 Output: flags.Filename(output), 26 } 27 testProduceOutput(t, v, specDoc, output) 28 } 29 30 func TestCmd_Expand_NoOutputFile(t *testing.T) { 31 specDoc := filepath.Join(fixtureBase, "bugs", "1536", "fixture-1536.yaml") 32 v := &ExpandSpec{ 33 Format: "json", 34 Compact: false, 35 Output: "", 36 } 37 result := v.Execute([]string{specDoc}) 38 assert.Nil(t, result) 39 } 40 41 func TestCmd_Expand_Error(t *testing.T) { 42 v := &ExpandSpec{} 43 testValidRefs(t, v) 44 }