diff --git a/.gitignore b/.gitignore index e6f1f80..af9ad9d 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ vendor Dockerfile.tmp .cover *.pid +*.db* diff --git a/config/config.go b/config/config.go index 8d77039..cf56239 100644 --- a/config/config.go +++ b/config/config.go @@ -150,11 +150,11 @@ func BuildDefaultPushConf() ConfYaml { conf.Stat.Redis.Password = "" conf.Stat.Redis.DB = 0 - conf.Stat.BoltDB.Path = "gorush.db" + conf.Stat.BoltDB.Path = "bolt.db" conf.Stat.BoltDB.Bucket = "gorush" - conf.Stat.BuntDB.Path = "gorush.db" - conf.Stat.LevelDB.Path = "gorush.db" + conf.Stat.BuntDB.Path = "bunt.db" + conf.Stat.LevelDB.Path = "level.db" return conf } diff --git a/config/config.yml b/config/config.yml index 1d31289..41d17ba 100644 --- a/config/config.yml +++ b/config/config.yml @@ -45,9 +45,9 @@ stat: password: "" db: 0 boltdb: - path: "gorush.db" + path: "bolt.db" bucket: "gorush" buntdb: - path: "gorush.db" + path: "bunt.db" leveldb: - path: "gorush.db" + path: "level.db" diff --git a/config/config_test.go b/config/config_test.go index 95af463..0014731 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -98,11 +98,11 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() { assert.Equal(suite.T(), "", suite.ConfGorushDefault.Stat.Redis.Password) assert.Equal(suite.T(), 0, suite.ConfGorushDefault.Stat.Redis.DB) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorushDefault.Stat.BoltDB.Path) + assert.Equal(suite.T(), "bolt.db", suite.ConfGorushDefault.Stat.BoltDB.Path) assert.Equal(suite.T(), "gorush", suite.ConfGorushDefault.Stat.BoltDB.Bucket) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorushDefault.Stat.BuntDB.Path) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorushDefault.Stat.LevelDB.Path) + assert.Equal(suite.T(), "bunt.db", suite.ConfGorushDefault.Stat.BuntDB.Path) + assert.Equal(suite.T(), "level.db", suite.ConfGorushDefault.Stat.LevelDB.Path) } func (suite *ConfigTestSuite) TestValidateConf() { @@ -151,11 +151,11 @@ func (suite *ConfigTestSuite) TestValidateConf() { assert.Equal(suite.T(), "", suite.ConfGorush.Stat.Redis.Password) assert.Equal(suite.T(), 0, suite.ConfGorush.Stat.Redis.DB) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorush.Stat.BoltDB.Path) + assert.Equal(suite.T(), "bolt.db", suite.ConfGorush.Stat.BoltDB.Path) assert.Equal(suite.T(), "gorush", suite.ConfGorush.Stat.BoltDB.Bucket) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorush.Stat.BuntDB.Path) - assert.Equal(suite.T(), "gorush.db", suite.ConfGorush.Stat.LevelDB.Path) + assert.Equal(suite.T(), "bunt.db", suite.ConfGorush.Stat.BuntDB.Path) + assert.Equal(suite.T(), "level.db", suite.ConfGorush.Stat.LevelDB.Path) } func TestConfigTestSuite(t *testing.T) { diff --git a/gorush/status_test.go b/gorush/status_test.go index cc79b74..75a67ad 100644 --- a/gorush/status_test.go +++ b/gorush/status_test.go @@ -120,3 +120,53 @@ func TestStatForBoltDBEngine(t *testing.T) { val = StatStorage.GetAndroidError() assert.Equal(t, int64(500), val) } + +func TestStatForBuntDBEngine(t *testing.T) { + var val int64 + PushConf.Stat.Engine = "buntdb" + InitAppStatus() + + StatStorage.Reset() + + StatStorage.AddTotalCount(100) + StatStorage.AddIosSuccess(200) + StatStorage.AddIosError(300) + StatStorage.AddAndroidSuccess(400) + StatStorage.AddAndroidError(500) + + val = StatStorage.GetTotalCount() + assert.Equal(t, int64(100), val) + val = StatStorage.GetIosSuccess() + assert.Equal(t, int64(200), val) + val = StatStorage.GetIosError() + assert.Equal(t, int64(300), val) + val = StatStorage.GetAndroidSuccess() + assert.Equal(t, int64(400), val) + val = StatStorage.GetAndroidError() + assert.Equal(t, int64(500), val) +} + +// func TestStatForLevelDBEngine(t *testing.T) { +// var val int64 +// PushConf.Stat.Engine = "leveldb" +// InitAppStatus() + +// StatStorage.Reset() + +// StatStorage.AddTotalCount(100) +// StatStorage.AddIosSuccess(200) +// StatStorage.AddIosError(300) +// StatStorage.AddAndroidSuccess(400) +// StatStorage.AddAndroidError(500) + +// val = StatStorage.GetTotalCount() +// assert.Equal(t, int64(100), val) +// val = StatStorage.GetIosSuccess() +// assert.Equal(t, int64(200), val) +// val = StatStorage.GetIosError() +// assert.Equal(t, int64(300), val) +// val = StatStorage.GetAndroidSuccess() +// assert.Equal(t, int64(400), val) +// val = StatStorage.GetAndroidError() +// assert.Equal(t, int64(500), val) +// }