diff --git a/shows/shows.go b/shows/shows.go index 1174b70..7876766 100644 --- a/shows/shows.go +++ b/shows/shows.go @@ -42,12 +42,12 @@ const ( ) var ( - // NotFound error returned when show not found in database + // ErrNotFound error returned when show not found in database ErrNotFound = fmt.Errorf("Not found") ) type Show struct { - sqly.BaseTable + sqly.BaseModel polochon.Show Episodes []*Episode TrackedSeason int @@ -213,7 +213,7 @@ func (s *Show) GetEpisodes(db *sqlx.DB) error { } type Episode struct { - sqly.BaseTable + sqly.BaseModel polochon.ShowEpisode } diff --git a/sqly/sqly.go b/sqly/sqly.go index 670e8c4..3d1c5eb 100644 --- a/sqly/sqly.go +++ b/sqly/sqly.go @@ -9,13 +9,14 @@ import ( "github.com/mattes/migrate/migrate" ) -// BaseTable have to be embeded in all your struct which reflect a table -type BaseTable struct { +// BaseModel have to be embeded in all your struct which reflect a table +type BaseModel struct { ID string Updated time.Time Created time.Time } +// RunWithLastestMigration runs your test with database migration set to the lastest func RunWithLastestMigration(db *sqlx.DB, pgdsn string, t *testing.T, test func(db *sqlx.DB, t *testing.T)) { defer func() { allErrors, ok := migrate.DownSync(pgdsn, "../sql") diff --git a/users/users.go b/users/users.go index b837d73..b23b292 100644 --- a/users/users.go +++ b/users/users.go @@ -22,14 +22,14 @@ const ( // User represents an user type User struct { - sqly.BaseTable + sqly.BaseModel Name string Hash string } // Token represents a token type Token struct { - sqly.BaseTable + sqly.BaseModel Value string }