Exemple #1
0
func TestOptions(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	db, err := redis.Open(redis.UnixConnection("", 0), redis.PoolSize(5))
	assert.Nil(err)
	defer db.Close()

	options := db.Options()
	assert.Equal(options.Address, "/tmp/redis.sock")
	assert.Equal(options.Network, "unix")
	assert.Equal(options.Timeout, 30*time.Second)
	assert.Equal(options.Index, 0)
	assert.Equal(options.Password, "")
	assert.Equal(options.PoolSize, 5)
	assert.Equal(options.Logging, false)
	assert.Equal(options.Monitoring, false)
}
Exemple #2
0
func TestConcurrency(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	db, err := redis.Open(redis.UnixConnection("", 0), redis.PoolSize(5))
	assert.Nil(err)
	defer db.Close()

	for i := 0; i < 500; i++ {
		go func() {
			conn, err := db.Connection()
			assert.Nil(err)
			defer conn.Return()
			result, err := conn.Do("ping")
			assert.Nil(err)
			assertEqualString(assert, result, 0, "+PONG")
			time.Sleep(10 * time.Millisecond)
		}()
	}
}