From 90825c5ff989dcde25156e923e827b6a20b7c0cd Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 21 Apr 2015 03:19:31 -0700 Subject: [PATCH] Rename qconfig as q as it makes sense to call it q.Config instead of qconfig.Config - one more test added for CheckData() --- pkg/{qconfig/qconfig.go => q/q.go} | 4 +- pkg/{qconfig/qconfig_test.go => q/q_test.go} | 46 ++++++++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) rename pkg/{qconfig/qconfig.go => q/q.go} (98%) rename pkg/{qconfig/qconfig_test.go => q/q_test.go} (73%) diff --git a/pkg/qconfig/qconfig.go b/pkg/q/q.go similarity index 98% rename from pkg/qconfig/qconfig.go rename to pkg/q/q.go index c3bda75d..8f44af72 100644 --- a/pkg/qconfig/qconfig.go +++ b/pkg/q/q.go @@ -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" diff --git a/pkg/qconfig/qconfig_test.go b/pkg/q/q_test.go similarity index 73% rename from pkg/qconfig/qconfig_test.go rename to pkg/q/q_test.go index b1c6152e..c1f85cec 100644 --- a/pkg/qconfig/qconfig_test.go +++ b/pkg/q/q_test.go @@ -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()) + // } }