-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from k1LoW/add-table-def
Add schema.Table.Def for show table/view definition
- Loading branch information
Showing
24 changed files
with
437 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package mysql | ||
|
||
import ( | ||
"database/sql" | ||
_ "github.com/go-sql-driver/mysql" | ||
"github.com/k1LoW/tbls/schema" | ||
"github.com/xo/dburl" | ||
"os" | ||
"testing" | ||
) | ||
|
||
var s *schema.Schema | ||
var db *sql.DB | ||
|
||
func TestMain(m *testing.M) { | ||
s = &schema.Schema{ | ||
Name: "testdb", | ||
} | ||
db, _ = dburl.Open("my://root:mypass@localhost:33306/testdb") | ||
defer db.Close() | ||
exit := m.Run() | ||
if exit != 0 { | ||
os.Exit(exit) | ||
} | ||
} | ||
|
||
func TestAnalyzeView(t *testing.T) { | ||
driver := new(Mysql) | ||
err := driver.Analyze(db, s) | ||
if err != nil { | ||
t.Errorf("%v", err) | ||
} | ||
view, _ := s.FindTableByName("post_comments") | ||
expected := view.Def | ||
if expected == "" { | ||
t.Errorf("actual not empty string.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package postgres | ||
|
||
import ( | ||
"database/sql" | ||
"github.com/k1LoW/tbls/schema" | ||
_ "github.com/lib/pq" | ||
"github.com/xo/dburl" | ||
"os" | ||
"testing" | ||
) | ||
|
||
var s *schema.Schema | ||
var db *sql.DB | ||
|
||
func TestMain(m *testing.M) { | ||
s = &schema.Schema{ | ||
Name: "testdb", | ||
} | ||
db, _ = dburl.Open("pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable") | ||
defer db.Close() | ||
exit := m.Run() | ||
if exit != 0 { | ||
os.Exit(exit) | ||
} | ||
} | ||
|
||
func TestAnalyzeView(t *testing.T) { | ||
driver := new(Postgres) | ||
err := driver.Analyze(db, s) | ||
if err != nil { | ||
t.Errorf("%v", err) | ||
} | ||
view, _ := s.FindTableByName("post_comments") | ||
expected := view.Def | ||
if expected == "" { | ||
t.Errorf("actual not empty string.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.