diff options
| author | Felix Hanley <felix@userspace.com.au> | 2017-06-11 13:25:57 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2017-06-11 13:29:15 +0000 |
| commit | 3185a43420dab2efb85aa601bdfe267e8b2e11f2 (patch) | |
| tree | 846c21d92f7089e3e43c2fec3dbee90aef938f9b /vendor/github.com/jackc/pgx/conn_pool_private_test.go | |
| parent | 3291eddb975a1df77975d8083599b5f3a85afaba (diff) | |
| download | dhtsearch-3185a43420dab2efb85aa601bdfe267e8b2e11f2.tar.gz dhtsearch-3185a43420dab2efb85aa601bdfe267e8b2e11f2.tar.bz2 | |
Add torrent tagging
- Move to postgresql to reduce locking issues
- Move ih hash to single thread
- Clean up stuff
Diffstat (limited to 'vendor/github.com/jackc/pgx/conn_pool_private_test.go')
| -rw-r--r-- | vendor/github.com/jackc/pgx/conn_pool_private_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/jackc/pgx/conn_pool_private_test.go b/vendor/github.com/jackc/pgx/conn_pool_private_test.go new file mode 100644 index 0000000..ef0ec1d --- /dev/null +++ b/vendor/github.com/jackc/pgx/conn_pool_private_test.go @@ -0,0 +1,44 @@ +package pgx + +import ( + "testing" +) + +func compareConnSlices(slice1, slice2 []*Conn) bool { + if len(slice1) != len(slice2) { + return false + } + for i, c := range slice1 { + if c != slice2[i] { + return false + } + } + return true +} + +func TestConnPoolRemoveFromAllConnections(t *testing.T) { + t.Parallel() + pool := ConnPool{} + conn1 := &Conn{} + conn2 := &Conn{} + conn3 := &Conn{} + + // First element + pool.allConnections = []*Conn{conn1, conn2, conn3} + pool.removeFromAllConnections(conn1) + if !compareConnSlices(pool.allConnections, []*Conn{conn2, conn3}) { + t.Fatal("First element test failed") + } + // Element somewhere in the middle + pool.allConnections = []*Conn{conn1, conn2, conn3} + pool.removeFromAllConnections(conn2) + if !compareConnSlices(pool.allConnections, []*Conn{conn1, conn3}) { + t.Fatal("Middle element test failed") + } + // Last element + pool.allConnections = []*Conn{conn1, conn2, conn3} + pool.removeFromAllConnections(conn3) + if !compareConnSlices(pool.allConnections, []*Conn{conn1, conn2}) { + t.Fatal("Last element test failed") + } +} |
