-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed to prevent panics by wrong usage * added afterOpen to give dialect a chance to initial setup
- Loading branch information
1 parent
29bb60f
commit 264e655
Showing
7 changed files
with
98 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
package pop | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_Connection_SimpleFlow(t *testing.T) { | ||
r := require.New(t) | ||
|
||
cd := &ConnectionDetails{ | ||
URL: "sqlite:///foo.db", | ||
} | ||
c, err := NewConnection(cd) | ||
r.NoError(err) | ||
|
||
err = c.Open() | ||
r.NoError(err) | ||
err = c.Open() // open again | ||
r.NoError(err) | ||
err = c.Close() | ||
r.NoError(err) | ||
} | ||
|
||
func Test_Connection_Open_NoDialect(t *testing.T) { | ||
r := require.New(t) | ||
|
||
cd := &ConnectionDetails{ | ||
URL: "sqlite:///foo.db", | ||
} | ||
c, err := NewConnection(cd) | ||
r.NoError(err) | ||
|
||
c.Dialect = nil | ||
err = c.Open() | ||
r.Error(err) | ||
} | ||
|
||
func Test_Connection_Open_BadDialect(t *testing.T) { | ||
r := require.New(t) | ||
|
||
cd := &ConnectionDetails{ | ||
URL: "sqlite:///foo.db", | ||
} | ||
c, err := NewConnection(cd) | ||
r.NoError(err) | ||
|
||
cd.Dialect = "unknown" | ||
err = c.Open() | ||
r.Error(err) | ||
} |
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