Skip to content

Commit

Permalink
chore: add docs.go test coverage (#482)
Browse files Browse the repository at this point in the history
* docs.go test coverage

* docs.go test coverage
  • Loading branch information
ubogdan authored and easonlin404 committed Jul 30, 2019
1 parent c2f6613 commit 77b9020
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ clean:
.PHONY: install
install:
$(GOGET) -v github.com/swaggo/swag github.com/swaggo/swag/cmd/swag github.com/swaggo/swag/gen
$(GOGET) github.com/alecthomas/template
$(GOGET) github.com/stretchr/testify/assert

.PHONY: lint
Expand Down
23 changes: 23 additions & 0 deletions gen/gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gen
import (
"github.com/go-openapi/spec"
"os"
"os/exec"
"path"
"path/filepath"
"testing"
Expand Down Expand Up @@ -245,3 +246,25 @@ func TestGen_writeGoDoc(t *testing.T) {
packageTemplate = swapTemplate

}

func TestGen_GeneratedDoc(t *testing.T) {

searchDir := "../testdata/simple"

config := &Config{
SearchDir: searchDir,
MainAPIFile: "./main.go",
OutputDir: "../testdata/simple/docs",
PropNamingStrategy: "",
}

assert.NoError(t, New().Build(config))
gocmd, err := exec.LookPath("go")
assert.NoError(t, err)

cmd := exec.Command(gocmd, "build", filepath.Join(config.OutputDir, "docs.go"))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

assert.NoError(t, cmd.Run())
}

0 comments on commit 77b9020

Please sign in to comment.