Skip to content

Commit

Permalink
fix: test data move to testdata dir (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
pei0804 authored and easonlin404 committed Mar 13, 2018
1 parent 27a8f10 commit 003fc1e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
swag
example/simple/docs
testdata/simple/docs

# Test binary, build with `go test -c`
*.test
Expand Down
8 changes: 4 additions & 4 deletions gen/gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import (
)

func TestGen_Build(t *testing.T) {
searchDir := "../example/simple"
searchDir := "../testdata/simple"
assert.NotPanics(t, func() {
New().Build(searchDir, "./main.go", "../example/simple/docs/swagger")
New().Build(searchDir, "./main.go", "../testdata/simple/docs/swagger")
})

if _, err := os.Stat(path.Join(searchDir, "docs", "docs.go")); os.IsNotExist(err) {
t.Fatal(err)
}
if _, err := os.Stat(path.Join("../example/simple/docs/swagger", "swagger.json")); os.IsNotExist(err) {
if _, err := os.Stat(path.Join("../testdata/simple/docs/swagger", "swagger.json")); os.IsNotExist(err) {
t.Fatal(err)
}
if _, err := os.Stat(path.Join("../example/simple/docs/swagger", "swagger.yaml")); os.IsNotExist(err) {
if _, err := os.Stat(path.Join("../testdata/simple/docs/swagger", "swagger.yaml")); os.IsNotExist(err) {
t.Fatal(err)
}
}
12 changes: 6 additions & 6 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ func TestParser_ParseGeneralApiInfoFailed(t *testing.T) {
}

func TestGetAllGoFileInfo(t *testing.T) {
searchDir := "example/pet"
searchDir := "testdata/pet"

p := New()
p.getAllGoFileInfo(searchDir)

assert.NotEmpty(t, p.files["example/pet/main.go"])
assert.NotEmpty(t, p.files["example/pet/web/handler.go"])
assert.NotEmpty(t, p.files["testdata/pet/main.go"])
assert.NotEmpty(t, p.files["testdata/pet/web/handler.go"])
assert.Equal(t, 2, len(p.files))
}

func TestParser_ParseType(t *testing.T) {
searchDir := "example/simple/"
searchDir := "testdata/simple/"

p := New()
p.getAllGoFileInfo(searchDir)
Expand Down Expand Up @@ -390,7 +390,7 @@ func TestParseSimpleApi(t *testing.T) {
}
}
}`
searchDir := "example/simple"
searchDir := "testdata/simple"
mainAPIFile := "main.go"
p := New()
p.ParseAPI(searchDir, mainAPIFile)
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestParsePetApi(t *testing.T) {
"basePath": "/v2",
"paths": {}
}`
searchDir := "example/pet"
searchDir := "testdata/pet"
mainAPIFile := "main.go"
p := New()
p.ParseAPI(searchDir, mainAPIFile)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 003fc1e

Please sign in to comment.