diff --git a/README.md b/README.md index fc7767e..3037961 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Golang Dirty Filter [![GoDoc](https://godoc.org/github.com/antlinker/go-dirtyfilter?status.svg)](https://godoc.org/github.com/antlinker/go-dirtyfilter) -[![wercker status](https://app.wercker.com/status/02cb69dcbba94ee4274f1c0c06ce68f9/s "wercker status")](https://app.wercker.com/project/bykey/02cb69dcbba94ee4274f1c0c06ce68f9) > 基于DFA算法; > 支持动态修改敏感词,同时支持特殊字符的筛选; diff --git a/store/mongo_test.go b/store/mongo_test.go index 8bd2f43..4d5d83a 100644 --- a/store/mongo_test.go +++ b/store/mongo_test.go @@ -1,62 +1,63 @@ package store_test -// import ( -// "github.com/antlinker/go-dirtyfilter/store" -// . "github.com/onsi/ginkgo" -// . "github.com/onsi/gomega" -// ) +import ( + "github.com/antlinker/go-dirtyfilter/store" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) -// var _ = Describe("敏感词MongoDB存储测试", func() { -// var ( -// mgoStore *store.MongoStore -// ) -// BeforeEach(func() { -// s, err := store.NewMongoStore(store.MongoConfig{ -// URL: "mongodb://localhost:27017/sample?maxPoolSize=128", -// }) -// if err != nil { -// Fail(err.Error()) -// return -// } -// mgoStore = s -// err = s.Write("共产党") -// if err != nil { -// Fail(err.Error()) -// return -// } -// }) -// It("Read Test", func() { -// for v := range mgoStore.Read() { -// Expect(v).To(Equal("共产党")) -// } -// }) -// It("ReadAll Test", func() { -// result, err := mgoStore.ReadAll() -// if err != nil { -// Fail(err.Error()) -// return -// } -// Expect(result).To(Equal([]string{"共产党"})) -// }) -// It("Version Test", func() { -// Expect(mgoStore.Version()).To(Equal(uint64(1))) -// err := mgoStore.Write("党") -// if err != nil { -// Fail(err.Error()) -// return -// } -// Expect(mgoStore.Version()).To(Equal(uint64(2))) -// err = mgoStore.Remove("党") -// if err != nil { -// Fail(err.Error()) -// return -// } -// }) -// AfterEach(func() { -// err := mgoStore.Remove("共产党") -// if err != nil { -// Fail(err.Error()) -// return -// } -// }) -// }) +var _ = Describe("敏感词MongoDB存储测试", func() { + var ( + mgoStore *store.MongoStore + ) + BeforeEach(func() { + s, err := store.NewMongoStore(store.MongoConfig{ + URL: "mongodb://admin:123456@192.168.33.70:27017", + DB: "sample", + }) + if err != nil { + Fail(err.Error()) + return + } + mgoStore = s + err = s.Write("共产党") + if err != nil { + Fail(err.Error()) + return + } + }) + It("Read Test", func() { + for v := range mgoStore.Read() { + Expect(v).To(Equal("共产党")) + } + }) + It("ReadAll Test", func() { + result, err := mgoStore.ReadAll() + if err != nil { + Fail(err.Error()) + return + } + Expect(result).To(Equal([]string{"共产党"})) + }) + It("Version Test", func() { + Expect(mgoStore.Version()).To(Equal(uint64(1))) + err := mgoStore.Write("党") + if err != nil { + Fail(err.Error()) + return + } + Expect(mgoStore.Version()).To(Equal(uint64(2))) + err = mgoStore.Remove("党") + if err != nil { + Fail(err.Error()) + return + } + }) + AfterEach(func() { + err := mgoStore.Remove("共产党") + if err != nil { + Fail(err.Error()) + return + } + }) +})