예제 #1
0
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)
}
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)
}
예제 #3
0
/* transform response by ValType, if none default:csv */
func responseByValType(valType string, response_map golhashmap.HashMap) string {
	var response string

	switch valType {
	case "csv", "json":
		hashmapEngine := golhashmap.GetHashMapEngine(valType)
		response = hashmapEngine.FromHashMap(response_map)

	default:
		response = golhashmap.HashMapToCSV(response_map)
	}
	return response
}