Skip to content

Commit

Permalink
Merge master into development (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m authored Aug 19, 2018
1 parent 3c0ed2d commit 4fec9f9
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 311 deletions.
9 changes: 4 additions & 5 deletions belongs_to_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package pop_test
package pop

import (
"testing"

"github.com/gobuffalo/pop"
"github.com/stretchr/testify/require"
)

Expand All @@ -12,7 +11,7 @@ func Test_BelongsTo(t *testing.T) {

q := PDB.BelongsTo(&User{ID: 1})

m := &pop.Model{Value: &Enemy{}}
m := &Model{Value: &Enemy{}}

sql, _ := q.ToSQL(m)
r.Equal(ts("SELECT enemies.A FROM enemies AS enemies WHERE user_id = ?"), sql)
Expand All @@ -23,7 +22,7 @@ func Test_BelongsToAs(t *testing.T) {

q := PDB.BelongsToAs(&User{ID: 1}, "u_id")

m := &pop.Model{Value: &Enemy{}}
m := &Model{Value: &Enemy{}}

sql, _ := q.ToSQL(m)
r.Equal(ts("SELECT enemies.A FROM enemies AS enemies WHERE u_id = ?"), sql)
Expand All @@ -35,7 +34,7 @@ func Test_BelongsToThrough(t *testing.T) {
q := PDB.BelongsToThrough(&User{ID: 1}, &Friend{})
qs := "SELECT enemies.A FROM enemies AS enemies, good_friends AS good_friends WHERE good_friends.user_id = ? AND enemies.id = good_friends.enemy_id"

m := &pop.Model{Value: &Enemy{}}
m := &Model{Value: &Enemy{}}
sql, _ := q.ToSQL(m)
r.Equal(ts(qs), sql)
}
13 changes: 6 additions & 7 deletions benchmarks_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package pop_test
package pop

import (
"fmt"
"strconv"
"testing"

"github.com/gobuffalo/pop"
"github.com/gobuffalo/pop/nulls"
)

func Benchmark_Create_Pop(b *testing.B) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
for n := 0; n < b.N; n++ {
u := &User{
Name: nulls.NewString("Mark Bates"),
Expand All @@ -21,7 +20,7 @@ func Benchmark_Create_Pop(b *testing.B) {
}

func Benchmark_Create_Raw(b *testing.B) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
for n := 0; n < b.N; n++ {
u := &User{
Name: nulls.NewString("Mark Bates"),
Expand All @@ -33,7 +32,7 @@ func Benchmark_Create_Raw(b *testing.B) {
}

func Benchmark_Update(b *testing.B) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
u := &User{
Name: nulls.NewString("Mark Bates"),
}
Expand All @@ -45,7 +44,7 @@ func Benchmark_Update(b *testing.B) {
}

func Benchmark_Find_Pop(b *testing.B) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
u := &User{
Name: nulls.NewString("Mark Bates"),
}
Expand All @@ -57,7 +56,7 @@ func Benchmark_Find_Pop(b *testing.B) {
}

func Benchmark_Find_Raw(b *testing.B) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
u := &User{
Name: nulls.NewString("Mark Bates"),
}
Expand Down
7 changes: 3 additions & 4 deletions callbacks_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package pop_test
package pop

import (
"testing"

"github.com/gobuffalo/pop"
"github.com/stretchr/testify/require"
)

func Test_Callbacks(t *testing.T) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
r := require.New(t)

user := &CallbacksUser{
Expand Down Expand Up @@ -52,7 +51,7 @@ func Test_Callbacks(t *testing.T) {
}

func Test_Callbacks_on_Slice(t *testing.T) {
transaction(func(tx *pop.Connection) {
transaction(func(tx *Connection) {
r := require.New(t)
for i := 0; i < 2; i++ {
r.NoError(tx.Create(&CallbacksUser{}))
Expand Down
9 changes: 4 additions & 5 deletions config_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package pop_test
package pop

import (
"testing"

"github.com/gobuffalo/pop"
"github.com/stretchr/testify/require"
)

func Test_LoadsConnectionsFromConfig(t *testing.T) {
r := require.New(t)

conns := pop.Connections
conns := Connections
r.Equal(5, len(conns))
}

func Test_AddLookupPaths(t *testing.T) {
r := require.New(t)
pop.AddLookupPaths("./foo")
r.Contains(pop.LookupPaths(), "./foo")
AddLookupPaths("./foo")
r.Contains(LookupPaths(), "./foo")
}
17 changes: 8 additions & 9 deletions connection_details_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package pop_test
package pop

import (
"testing"

"github.com/gobuffalo/pop"
"github.com/stretchr/testify/require"
)

func Test_ConnectionDetails_Finalize(t *testing.T) {
r := require.New(t)

cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: "postgres://user:pass@host:port/database",
}
err := cd.Finalize()
Expand All @@ -28,7 +27,7 @@ func Test_ConnectionDetails_Finalize_MySQL_DSN(t *testing.T) {
r := require.New(t)

url := "mysql://user:pass@(host:port)/database?param1=value1&param2=value2"
cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: url,
}
err := cd.Finalize()
Expand All @@ -53,7 +52,7 @@ func Test_ConnectionDetails_Finalize_MySQL_DSN_collation(t *testing.T) {
}

for _, url := range urls {
cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: url,
}
err := cd.Finalize()
Expand All @@ -74,7 +73,7 @@ func Test_ConnectionDetails_Finalize_MySQL_DSN_Protocol(t *testing.T) {
r := require.New(t)

url := "mysql://user:pass@tcp(host:port)/protocol"
cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: url,
}
err := cd.Finalize()
Expand All @@ -93,7 +92,7 @@ func Test_ConnectionDetails_Finalize_MySQL_DSN_Socket(t *testing.T) {
r := require.New(t)

url := "mysql://user:pass@unix(/path/to/socket)/socket"
cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: url,
}
err := cd.Finalize()
Expand All @@ -110,7 +109,7 @@ func Test_ConnectionDetails_Finalize_MySQL_DSN_Socket(t *testing.T) {

func Test_ConnectionDetails_Finalize_UnknownDialect(t *testing.T) {
r := require.New(t)
cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: "unknown://user:pass@host:port/database",
}
err := cd.Finalize()
Expand All @@ -120,7 +119,7 @@ func Test_ConnectionDetails_Finalize_UnknownDialect(t *testing.T) {
func Test_ConnectionDetails_Finalize_SQLite(t *testing.T) {
r := require.New(t)

cd := &pop.ConnectionDetails{
cd := &ConnectionDetails{
URL: "sqlite3:///tmp/foo.db",
}
err := cd.Finalize()
Expand Down
2 changes: 1 addition & 1 deletion connection_test.go
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package pop_test
package pop
Loading

0 comments on commit 4fec9f9

Please sign in to comment.