當前位置: 首頁>>代碼示例>>Golang>>正文


Golang leveldb.CloseAndDeleteDB函數代碼示例

本文整理匯總了Golang中github.com/abhishekkr/levigoNS/leveldb.CloseAndDeleteDB函數的典型用法代碼示例。如果您正苦於以下問題:Golang CloseAndDeleteDB函數的具體用法?Golang CloseAndDeleteDB怎麽用?Golang CloseAndDeleteDB使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CloseAndDeleteDB函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestReadNSRecursive

func TestReadNSRecursive(t *testing.T) {
	_parentKey, _key, _childKey := "abc", "abc:name", "abc:name:last"
	expectedParentKeyVal := "abc:name,ABC XYZ\nabc:name:first,ABC\nabc:name:last,XYZ"
	expectedKeyVal := "abc:name,ABC XYZ\nabc:name:first,ABC\nabc:name:last,XYZ"
	expectedChildKeyVal := "abc:name:last,XYZ"

	db := abkleveldb.CreateDB(dbpath)
	setupTestData(db)

	resultParentKeyVal := golhashmap.HashMapToCSV(ReadNSRecursive(_parentKey, db))
	resultKeyVal := golhashmap.HashMapToCSV(ReadNSRecursive(_key, db))
	resultChildKeyVal := golhashmap.HashMapToCSV(ReadNSRecursive(_childKey, db))

	golassert.AssertEqualStringArray(
		strings.Split(expectedParentKeyVal, "\n"),
		strings.Split(resultParentKeyVal, "\n"),
	)
	golassert.AssertEqualStringArray(
		strings.Split(expectedKeyVal, "\n"),
		strings.Split(resultKeyVal, "\n"),
	)
	golassert.AssertEqualStringArray(
		strings.Split(expectedChildKeyVal, "\n"),
		strings.Split(resultChildKeyVal, "\n"),
	)

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:28,代碼來源:levigoNS_test.go

示例2: TestAppendKey

func TestAppendKey(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)

	status := appendKey("abc:name:first", "title", db)
	expectedVal := "key::abc:name:first:title"
	resultVal := abkleveldb.GetVal("key::abc:name:first", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	status = appendKey("abc", "name", db)
	expectedVal = "key::abc:name"
	resultVal = abkleveldb.GetVal("key::abc", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	status = appendKey("abc", "age", db)
	expectedVal = "key::abc:name,key::abc:age"
	resultVal = abkleveldb.GetVal("key::abc", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:35,代碼來源:levigoNS_test.go

示例3: TestCreateNS

func TestCreateNS(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)

	status := CreateNS("abc:name:first", db)
	expectedVal := "key::abc:name:first"
	resultVal := abkleveldb.GetVal("key::abc:name", db)
	if expectedVal != resultVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	status = CreateNS("abc:name:last", db)
	expectedVal = "key::abc:name:first,key::abc:name:last"
	resultVal = abkleveldb.GetVal("key::abc:name", db)
	if expectedVal != resultVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	status = CreateNS("abc:name:last", db)
	expectedVal = "key::abc:name:first,key::abc:name:last"
	resultVal = abkleveldb.GetVal("key::abc:name", db)
	if expectedVal != resultVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:35,代碼來源:levigoNS_test.go

示例4: TestDeleteNSRecursive

func TestDeleteNSRecursive(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)
	setupTestData(db)

	status := DeleteNSRecursive("abc", db)

	expectedVal := ""
	resultVal := abkleveldb.GetVal("key::abc", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	expectedVal = ""
	resultVal = abkleveldb.GetVal("key::abc:name", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	expectedVal = ""
	resultVal = abkleveldb.GetVal("val::abc:name:first", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	expectedVal = ""
	resultVal = abkleveldb.GetVal("val::abc:name:last", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:35,代碼來源:levigoNS_test.go

示例5: TestDeleteNSKey

func TestDeleteNSKey(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)
	setupTestData(db)

	status := DeleteNSKey("abc:name:last", db)

	expectedVal := ""
	resultVal := abkleveldb.GetVal("val::abc:name:last", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	expectedVal = "ABC"
	resultVal = abkleveldb.GetVal("val::abc:name:first", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	status = DeleteNSKey("abc:name:last", db)
	if !status {
		t.Error("Fail: Success in deleting non-existent key.")
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:28,代碼來源:levigoNS_test.go

示例6: TestReadKey

func TestReadKey(t *testing.T) {
	setupTestData()

	expected_val := "upstate:2014:January:2:12:1:20,down"
	result_val := golhashmap.HashMapToCSV(ReadKey("upstate:2014:January:2:12:1:20"))
	golassert.AssertEqual(expected_val, result_val)

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:9,代碼來源:dbtasks_test.go

示例7: TestGetVal

func TestGetVal(t *testing.T) {
	setupTestData()

	expected_val := "down"
	result_val := GetVal("upstate:2014:January:2:12:1:20")
	if expected_val != result_val {
		t.Error("Fail: Get", result_val, "instead of", expected_val)
	}

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:ChaacMonitoring,項目名稱:goshare,代碼行數:11,代碼來源:dbtasks_test.go

示例8: TestDelKeyNS

func TestDelKeyNS(t *testing.T) {
	setupTestData()

	status := DelKeyNS("upstate:2014")
	expected_val := ""
	result_val := abkleveldb.GetVal("val::upstate:2014:January:2:12:1:20", db)
	if expected_val != result_val {
		t.Error("Fail: Get", result_val, "instead of", expected_val)
	}
	if !status {
		t.Error("Fail: Wrong status returned by DelKeyNS")
	}

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:15,代碼來源:dbtasks_test.go

示例9: TestPushKeyValNS

func TestPushKeyValNS(t *testing.T) {
	setupTestData()

	expected_val := "right"
	status := PushKeyValNS("oh:yeah", expected_val)
	result_val := abkleveldb.GetVal("val::oh:yeah", db)
	if expected_val != result_val {
		t.Error("Fail: Get", result_val, "instead of", expected_val)
	}
	if !status {
		t.Error("Fail: Wrong status returned by PushKeyValNS")
	}

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:15,代碼來源:dbtasks_test.go

示例10: TestPushKeyValTSDS

func TestPushKeyValTSDS(t *testing.T) {
	setupTestData()

	ohtime := goltime.Timestamp{
		Year: 2014, Month: 1, Day: 2, Hour: 12, Min: 1, Sec: 20,
	}
	status := PushKeyValTSDS("oh", "yeah", ohtime)
	expected_val := "yeah"
	result_val := abkleveldb.GetVal("val::oh:2014:January:2:12:1:20", db)
	if expected_val != result_val {
		t.Error("Fail: Get", result_val, "instead of", expected_val)
	}
	if !status {
		t.Error("Fail: Wrong status returned by PushKeyValTSDS")
	}

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:ChaacMonitoring,項目名稱:goshare,代碼行數:18,代碼來源:dbtasks_test.go

示例11: TestDeleteNSChildren

func TestDeleteNSChildren(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)
	setupTestData(db)

	expectedVal := "ABC XYZ"
	resultVal := abkleveldb.GetVal("val::abc:name", db)
	if resultVal != expectedVal {
		t.Error("Fail: Pre-req is bad.")
	}

	status := deleteNSChildren("key::abc:name", db)
	expectedVal = ""
	resultVal = abkleveldb.GetVal("val::abc:name", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	expectedVal = ""
	resultVal = abkleveldb.GetVal("key::abc:name", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	expectedVal = "XYZ"
	resultVal = abkleveldb.GetVal("val::abc:name:last", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	status = deleteNSChildren("key::abc:name:first,key::abc:name:last", db)
	expectedVal = ""
	resultVal = abkleveldb.GetVal("val::abc:name:first", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:44,代碼來源:levigoNS_test.go

示例12: TestPushNS

func TestPushNS(t *testing.T) {
	db := abkleveldb.CreateDB(dbpath)

	status := PushNS("abc:name", "ABC XYZ", db)
	expectedVal := "ABC XYZ"
	resultVal := abkleveldb.GetVal("val::abc:name", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}
	if !status {
		t.Error("Fail: Failed Status for", expectedVal)
	}

	expectedVal = "key::abc:name"
	resultVal = abkleveldb.GetVal("key::abc", db)
	if resultVal != expectedVal {
		t.Error("Fail: Get", resultVal, "instead of", expectedVal)
	}

	abkleveldb.CloseAndDeleteDB(dbpath, db)
}
開發者ID:carriercomm,項目名稱:levigoNS,代碼行數:21,代碼來源:levigoNS_test.go

示例13: TestPushKeyValTSDS

func TestPushKeyValTSDS(t *testing.T) {
	setupTestData()
	packet := Packet{}
	packet.HashMap = make(golhashmap.HashMap)
	packet.HashMap["oh"] = "yeah"
	packet.ParentNS = "phrase"
	packet.TimeDot = goltime.Timestamp{
		Year: 2014, Month: 1, Day: 2, Hour: 12, Min: 1, Sec: 20,
	}
	packet.KeyType = "tsds"

	status := PushFromPacket(packet)
	expected_val := "yeah"
	result_val := abkleveldb.GetVal("val::oh:2014:January:2:12:1:20", db)
	golassert.AssertEqual(expected_val, result_val)
	if !status {
		t.Error("Fail: Wrong status returned by PushKeyValTSDS")
	}

	abkleveldb.CloseAndDeleteDB(test_dbpath, db)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:21,代碼來源:dbtasks_test.go


注:本文中的github.com/abhishekkr/levigoNS/leveldb.CloseAndDeleteDB函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。