Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Nov 18, 2018
1 parent dcb6c13 commit f534ddb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
10 changes: 9 additions & 1 deletion output/dot/dot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import (

func TestOutputSchema(t *testing.T) {
s := newTestSchema()
err := s.LoadAdditionalData(filepath.Join(testdataDir(), "md_test_additional_data.yml"))
if err != nil {
t.Error(err)
}
buf := &bytes.Buffer{}
err := OutputSchema(buf, s)
err = OutputSchema(buf, s)
if err != nil {
t.Error(err)
}
Expand All @@ -26,6 +30,10 @@ func TestOutputSchema(t *testing.T) {

func TestOutputTable(t *testing.T) {
s := newTestSchema()
err := s.LoadAdditionalData(filepath.Join(testdataDir(), "md_test_additional_data.yml"))
if err != nil {
t.Error(err)
}
ta := s.Tables[0]

buf := &bytes.Buffer{}
Expand Down
12 changes: 10 additions & 2 deletions output/md/md_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ var tests = []struct {
func TestOutput(t *testing.T) {
for _, tt := range tests {
s := newTestSchema()
err := s.LoadAdditionalData(filepath.Join(testdataDir(), "md_test_additional_data.yml"))
if err != nil {
t.Error(err)
}
tempDir, _ := ioutil.TempDir("", "tbls")
force := true
adjust := tt.adjust
erFormat := "png"
defer os.RemoveAll(tempDir)
err := Output(s, tempDir, force, adjust, erFormat)
err = Output(s, tempDir, force, adjust, erFormat)
if err != nil {
t.Error(err)
}
Expand All @@ -50,12 +54,16 @@ func TestOutput(t *testing.T) {
func TestDiff(t *testing.T) {
for _, tt := range tests {
s := newTestSchema()
err := s.LoadAdditionalData(filepath.Join(testdataDir(), "md_test_additional_data.yml"))
if err != nil {
t.Error(err)
}
tempDir, _ := ioutil.TempDir("", "tbls")
force := true
adjust := tt.adjust
erFormat := "png"
defer os.RemoveAll(tempDir)
err := Output(s, tempDir, force, adjust, erFormat)
err = Output(s, tempDir, force, adjust, erFormat)
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion testdata/md_test_README.md.adjust.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Name | Columns | Comment | Type |
| --------- | ------- | ------- | ---- |
| [a](a.md) | 2 | table a | |
| [a](a.md) | 2 | TABLE A | |
| [b](b.md) | 2 | table b | |

---
Expand Down
2 changes: 1 addition & 1 deletion testdata/md_test_README.md.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Name | Columns | Comment | Type |
| ---- | ------- | ------- | ---- |
| [a](a.md) | 2 | table a | |
| [a](a.md) | 2 | TABLE A | |
| [b](b.md) | 2 | table b | |

---
Expand Down
4 changes: 2 additions & 2 deletions testdata/md_test_a.md.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Description

table a
TABLE A

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| a | | | false | | [b](b.md) | column a |
| a | | | false | | [b](b.md) | COLUMN A |
| a2 | | | false | | | column a2 |

---
Expand Down
7 changes: 7 additions & 0 deletions testdata/md_test_additional_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
comments:
-
table: a
tableComment: TABLE A
columnComments:
a: COLUMN A

0 comments on commit f534ddb

Please sign in to comment.