本文整理匯總了Golang中camlistore/org/pkg/sorted/kvtest.TestSorted函數的典型用法代碼示例。如果您正苦於以下問題:Golang TestSorted函數的具體用法?Golang TestSorted怎麽用?Golang TestSorted使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了TestSorted函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestKvfileKV
func TestKvfileKV(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "camlistore-kvfilekv_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir)
dbname := filepath.Join(tmpDir, "testdb.kvfile")
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "kv",
"file": dbname,
})
if err != nil {
t.Fatalf("Could not create kvfile sorted kv at %v: %v", dbname, err)
}
kvtest.TestSorted(t, kv)
}
示例2: TestMongoKV
// TestMongoKV tests against a real MongoDB instance, using a Docker container.
func TestMongoKV(t *testing.T) {
// SetupMongoContainer may skip or fatal the test if docker isn't found or something goes wrong when setting up the container.
// Thus, no error is returned
containerID, ip := dockertest.SetupMongoContainer(t)
defer containerID.KillRemove(t)
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "mongo",
"host": ip,
"database": "camlitest",
})
if err != nil {
t.Fatalf("mongo.NewKeyValue = %v", err)
}
kvtest.TestSorted(t, kv)
}
示例3: TestLeveldbKV
func TestLeveldbKV(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "camlistore-leveldbkv_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir)
dbname := filepath.Join(tmpDir, "testdb.leveldb")
t.Logf("Testing leveldb %q.", dbname)
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "leveldb",
"file": dbname,
})
if err != nil {
t.Fatalf("Could not create leveldb sorted kv at %v: %v", dbname, err)
}
kvtest.TestSorted(t, kv)
}
示例4: TestMySQLKV
// TestMySQLKV tests against a real MySQL instance, using a Docker container.
func TestMySQLKV(t *testing.T) {
dbname := "camlitest_" + osutil.Username()
containerID, ip := dockertest.SetupMySQLContainer(t, dbname)
defer containerID.KillRemove(t)
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "mysql",
"host": ip + ":3306",
"database": dbname,
"user": dockertest.MySQLUsername,
"password": dockertest.MySQLPassword,
})
if err != nil {
t.Fatalf("mysql.NewKeyValue = %v", err)
}
kvtest.TestSorted(t, kv)
}
示例5: TestPostgreSQLKV
// TestPostgreSQLKV tests against a real PostgreSQL instance, using a Docker container.
func TestPostgreSQLKV(t *testing.T) {
dbname := "camlitest_" + osutil.Username()
containerID, ip := dockertest.SetupPostgreSQLContainer(t, dbname)
defer containerID.KillRemove(t)
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "postgres",
"host": ip,
"database": dbname,
"user": dockertest.PostgresUsername,
"password": dockertest.PostgresPassword,
"sslmode": "disable",
})
if err != nil {
t.Fatalf("postgres.NewKeyValue = %v", err)
}
kvtest.TestSorted(t, kv)
}
示例6: TestSQLiteKV
func TestSQLiteKV(t *testing.T) {
if !CompiledIn() {
t.Skip(ErrNotCompiled.Error())
}
tmpDir, err := ioutil.TempDir("", "camlistore-sqlitekv_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpDir)
dbname := filepath.Join(tmpDir, "testdb.sqlite")
kv, err := sorted.NewKeyValue(jsonconfig.Obj{
"type": "sqlite",
"file": dbname,
})
if err != nil {
t.Fatalf("Could not create sqlite sorted kv at %v: %v", dbname, err)
}
kvtest.TestSorted(t, kv)
}
示例7: TestMongoKV
// TestMongoKV tests against a real MongoDB instance, using a Docker container.
// Currently using https://index.docker.io/u/robinvdvleuten/mongo/
func TestMongoKV(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}
if _, err := exec.LookPath("docker"); err != nil {
t.Skip("skipping without docker available in path")
}
if ok, err := dockerHaveImage(mongoImage); !ok || err != nil {
if err != nil {
t.Skipf("Error running docker to check for %s: %v", mongoImage, err)
}
log.Printf("Pulling docker image %s ...", mongoImage)
if err := dockerPull(mongoImage); err != nil {
t.Skipf("Error pulling %s: %v", mongoImage, err)
}
}
containerID, err := dockerRun("-d", mongoImage, "--smallfiles")
if err != nil {
t.Fatalf("docker run: %v", err)
}
defer dockerKillContainer(containerID)
ip, err := dockerIP(containerID)
if err != nil {
t.Fatalf("Error getting container IP: %v", err)
}
if err := netutil.AwaitReachable(ip+":27017", 10*time.Second); err != nil {
t.Fatal("timeout waiting for port to become reachable")
}
kv, err := NewKeyValue(Config{
Server: ip,
Database: "camlitest",
})
if err != nil {
t.Fatalf("monogo.NewKeyValue = %v", err)
}
kvtest.TestSorted(t, kv)
}
示例8: TestSortedKV
func TestSortedKV(t *testing.T) {
kv, clean := newSorted(t)
defer clean()
kvtest.TestSorted(t, kv)
}
示例9: TestSorted_MySQL
func TestSorted_MySQL(t *testing.T) {
kv, clean := newMySQLSorted(t)
defer clean()
kvtest.TestSorted(t, kv)
}
示例10: TestSorted_Kvfile
func TestSorted_Kvfile(t *testing.T) {
kv, cleanup := newKvfileSorted(t)
defer cleanup()
kvtest.TestSorted(t, kv)
}
示例11: TestSorted_Postgres
func TestSorted_Postgres(t *testing.T) {
kv, clean := newPostgresSorted(t)
defer clean()
kvtest.TestSorted(t, kv)
}
示例12: TestMemoryKV
func TestMemoryKV(t *testing.T) {
kv := sorted.NewMemoryKeyValue()
kvtest.TestSorted(t, kv)
}
示例13: TestSorted_Mongo
func TestSorted_Mongo(t *testing.T) {
kv, cleanup := newMongoSorted(t)
defer cleanup()
kvtest.TestSorted(t, kv)
}
示例14: TestSorted_LevelDB
func TestSorted_LevelDB(t *testing.T) {
kv, cleanup := newLevelDBSorted(t)
defer cleanup()
kvtest.TestSorted(t, kv)
}