service_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package offer
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "reflect"
  7. "testing"
  8. "go-common/app/job/main/app-wall/conf"
  9. cluster "github.com/bsm/sarama-cluster"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../../cmd/app-wall-job-test.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. s = New(conf.Conf)
  20. }
  21. func TestNew(t *testing.T) {
  22. type args struct {
  23. c *conf.Config
  24. }
  25. tests := []struct {
  26. name string
  27. args args
  28. wantS *Service
  29. }{
  30. // TODO: Add test cases.
  31. }
  32. for _, tt := range tests {
  33. t.Run(tt.name, func(t *testing.T) {
  34. if gotS := New(tt.args.c); !reflect.DeepEqual(gotS, tt.wantS) {
  35. t.Errorf("New() = %v, want %v", gotS, tt.wantS)
  36. }
  37. })
  38. }
  39. }
  40. func TestService_Ping(t *testing.T) {
  41. type args struct {
  42. c context.Context
  43. }
  44. tests := []struct {
  45. name string
  46. s *Service
  47. args args
  48. wantErr bool
  49. }{
  50. // TODO: Add test cases.
  51. }
  52. for _, tt := range tests {
  53. t.Run(tt.name, func(t *testing.T) {
  54. if err := tt.s.Ping(tt.args.c); (err != nil) != tt.wantErr {
  55. t.Errorf("Service.Ping() error = %v, wantErr %v", err, tt.wantErr)
  56. }
  57. })
  58. }
  59. }
  60. func TestService_Close(t *testing.T) {
  61. tests := []struct {
  62. name string
  63. s *Service
  64. }{
  65. // TODO: Add test cases.
  66. }
  67. for _, tt := range tests {
  68. t.Run(tt.name, func(t *testing.T) {
  69. tt.s.Close()
  70. })
  71. }
  72. }
  73. func TestService_NewConsumer(t *testing.T) {
  74. tests := []struct {
  75. name string
  76. s *Service
  77. want *cluster.Consumer
  78. wantErr error
  79. }{
  80. // TODO: Add test cases.
  81. }
  82. for _, tt := range tests {
  83. Convey(tt.name, t, func() {
  84. got, err := tt.s.NewConsumer()
  85. So(err, ShouldEqual, tt.wantErr)
  86. So(got, ShouldResemble, tt.want)
  87. })
  88. }
  89. }