github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/cmd/swagger/commands/generate/markdown_test.go (about)

     1  package generate_test
     2  
     3  import (
     4  	"io"
     5  	"log"
     6  	"os"
     7  	"path/filepath"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  
    12  	"github.com/go-swagger/go-swagger/cmd/swagger/commands/generate"
    13  	flags "github.com/jessevdk/go-flags"
    14  )
    15  
    16  func TestMarkdown(t *testing.T) {
    17  	log.SetOutput(io.Discard)
    18  	defer log.SetOutput(os.Stdout)
    19  
    20  	base := filepath.FromSlash("../../../../")
    21  
    22  	generated, err := os.MkdirTemp(".", "test-markdown")
    23  	require.NoError(t, err)
    24  
    25  	defer func() {
    26  		_ = os.RemoveAll(generated)
    27  	}()
    28  
    29  	m := &generate.Markdown{}
    30  	_, _ = flags.ParseArgs(m, []string{"--skip-validation"})
    31  	m.Shared.Spec = flags.Filename(filepath.Join(base, "fixtures", "enhancements", "184", "fixture-184.yaml"))
    32  	m.Output = flags.Filename(filepath.Join(generated, "markdown.md"))
    33  	require.NoError(t, m.Execute([]string{}))
    34  }