dao_test.go 726 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package pendant
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/usersuit/conf"
  8. _ "github.com/go-sql-driver/mysql"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var d *Dao
  12. func init() {
  13. dir, _ := filepath.Abs("../cmd/convey-test.toml")
  14. flag.Set("conf", dir)
  15. conf.Init()
  16. d = New(conf.Conf)
  17. }
  18. func Test_Ping(t *testing.T) {
  19. Convey("should return err be nil", t, func() {
  20. err := d.Ping(context.TODO())
  21. So(err, ShouldBeNil)
  22. })
  23. }
  24. func Test_Close(t *testing.T) {
  25. Convey("should return err be nil", t, func() {
  26. d.Close()
  27. })
  28. }
  29. func Test_pingRedis(t *testing.T) {
  30. Convey("should return err be nil", t, func() {
  31. err := d.pingRedis(context.TODO())
  32. So(err, ShouldBeNil)
  33. })
  34. }