Merge pull request #474 from harshavardhana/pr_out_rename_qconfig_as_q_as_it_makes_sense_to_call_it_q_config_instead_of_qconfig_config

This commit is contained in:
Harshavardhana
2015-04-21 03:25:01 -07:00
2 changed files with 39 additions and 11 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* qconfig for config files and persistent state files
* q - Quick key value store for config files and persistent state files
*
* Mini Copy, (C) 2015 Minio, Inc.
*
@@ -16,7 +16,7 @@
* limitations under the License.
*/
package qconfig
package q
import (
"encoding/json"
@@ -1,5 +1,5 @@
/*
* qdb - Quick key value store for config files and persistent state files
* q - Quick key value store for config files and persistent state files
*
* Mini Copy, (C) 2015 Minio, Inc.
*
@@ -16,10 +16,9 @@
* limitations under the License.
*/
package qconfig
package q
import (
"fmt"
"os"
"testing"
@@ -32,6 +31,31 @@ type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestCheckData(c *C) {
err := CheckData(nil)
c.Assert(err, Not(IsNil))
type myStructBad struct {
User string
Password string
Folders []string
}
saveMeBad := myStructBad{"guest", "nopassword", []string{"Work", "Documents", "Music"}}
err = CheckData(&saveMeBad)
c.Assert(err, Not(IsNil))
type myStructGood struct {
Version string
User string
Password string
Folders []string
}
saveMeGood := myStructGood{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
err = CheckData(&saveMeGood)
c.Assert(err, IsNil)
}
func (s *MySuite) TestSaveLoad(c *C) {
defer os.RemoveAll("test.json")
type myStruct struct {
@@ -82,9 +106,11 @@ func (s *MySuite) TestDiff(c *C) {
fields, ok := config.Diff(newConfig)
c.Assert(ok, IsNil)
c.Assert(len(fields), Equals, 1)
for i, field := range fields {
fmt.Printf("Diff[%d]: %s=%v\n", i, field.Name(), field.Value())
}
// Uncomment for debugging
// for i, field := range fields {
// fmt.Printf("Diff[%d]: %s=%v\n", i, field.Name(), field.Value())
// }
}
func (s *MySuite) TestDeepDiff(c *C) {
@@ -105,7 +131,9 @@ func (s *MySuite) TestDeepDiff(c *C) {
fields, err := config.DeepDiff(newConfig)
c.Assert(err, IsNil)
c.Assert(len(fields), Equals, 2)
for i, field := range fields {
fmt.Printf("DeepDiff[%d]: %s=%v\n", i, field.Name(), field.Value())
}
// Uncomment for debugging
// for i, field := range fields {
// fmt.Printf("DeepDiff[%d]: %s=%v\n", i, field.Name(), field.Value())
// }
}