Add API tests for both donut on disk and donut cache

This commit is contained in:
Harshavardhana
2015-07-07 19:37:16 -07:00
parent c76d4f6cdd
commit d1deda3a96
7 changed files with 1068 additions and 147 deletions

View File

@@ -155,13 +155,12 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List
}
var prefixes []string
var filteredObjects []string
filteredObjects = objects
if strings.TrimSpace(delimiter) != "" {
filteredObjects = HasNoDelimiter(objects, delimiter)
prefixes = HasDelimiter(objects, delimiter)
prefixes = SplitDelimiter(prefixes, delimiter)
prefixes = SortU(prefixes)
} else {
filteredObjects = objects
}
var results []string
var commonPrefixes []string

View File

@@ -34,15 +34,15 @@ func getDonutConfigPath() (string, error) {
return donutConfigPath, nil
}
// NOTE - this is not to be used outside Donut package, this is primarily intended for testing purposes only
var customConfigPath string
// NOTE - this is not thread safe use it carefully, currently its purpose is only for testing purposes.
var CustomConfigPath string
// SaveConfig save donut config
func SaveConfig(a *Config) error {
var donutConfigPath string
var err error
if customConfigPath != "" {
donutConfigPath = customConfigPath
if CustomConfigPath != "" {
donutConfigPath = CustomConfigPath
} else {
donutConfigPath, err = getDonutConfigPath()
if err != nil {
@@ -63,8 +63,8 @@ func SaveConfig(a *Config) error {
func LoadConfig() (*Config, error) {
var donutConfigPath string
var err error
if customConfigPath != "" {
donutConfigPath = customConfigPath
if CustomConfigPath != "" {
donutConfigPath = CustomConfigPath
} else {
donutConfigPath, err = getDonutConfigPath()
if err != nil {

View File

@@ -66,7 +66,7 @@ func (s *MyDonutSuite) SetUpSuite(c *C) {
conf.DonutName = "test"
conf.NodeDiskMap = createTestNodeDiskMap(root)
conf.MaxSize = 100000
customConfigPath = filepath.Join(root, "donut.json")
CustomConfigPath = filepath.Join(root, "donut.json")
err = SaveConfig(conf)
c.Assert(err, IsNil)

View File

@@ -500,13 +500,12 @@ func (donut API) ListObjects(bucket string, resources BucketResourcesMetadata) (
}
var prefixes []string
var filteredKeys []string
filteredKeys = keys
if strings.TrimSpace(resources.Delimiter) != "" {
filteredKeys = HasNoDelimiter(keys, resources.Delimiter)
prefixes = HasDelimiter(keys, resources.Delimiter)
prefixes = SplitDelimiter(prefixes, resources.Delimiter)
prefixes = SortU(prefixes)
} else {
filteredKeys = keys
}
for _, commonPrefix := range prefixes {
resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix)

View File

@@ -44,7 +44,7 @@ func (s *MyCacheSuite) SetUpSuite(c *C) {
c.Assert(err, IsNil)
s.root = root
customConfigPath = filepath.Join(root, "donut.json")
CustomConfigPath = filepath.Join(root, "donut.json")
dc, err = New()
c.Assert(err, IsNil)