github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/cmd/gen-docs/main_test.go (about)

     1  package main
     2  
     3  import (
     4  	"os"
     5  	"strings"
     6  	"testing"
     7  )
     8  
     9  func Test_run(t *testing.T) {
    10  	dir := t.TempDir()
    11  	args := []string{"--man-page", "--website", "--doc-path", dir}
    12  	err := run(args)
    13  	if err != nil {
    14  		t.Fatalf("got error: %v", err)
    15  	}
    16  
    17  	manPage, err := os.ReadFile(dir + "/gh-issue-create.1")
    18  	if err != nil {
    19  		t.Fatalf("error reading `gh-issue-create.1`: %v", err)
    20  	}
    21  	if !strings.Contains(string(manPage), `\fB\fCgh issue create`) {
    22  		t.Fatal("man page corrupted")
    23  	}
    24  
    25  	markdownPage, err := os.ReadFile(dir + "/gh_issue_create.md")
    26  	if err != nil {
    27  		t.Fatalf("error reading `gh_issue_create.md`: %v", err)
    28  	}
    29  	if !strings.Contains(string(markdownPage), `## gh issue create`) {
    30  		t.Fatal("markdown page corrupted")
    31  	}
    32  }