memcache_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package archive
  2. import (
  3. "context"
  4. "go-common/app/service/main/archive/api"
  5. "reflect"
  6. "testing"
  7. )
  8. func Test_keyArc(t *testing.T) {
  9. type args struct {
  10. aid int64
  11. }
  12. tests := []struct {
  13. name string
  14. args args
  15. want string
  16. }{
  17. // TODO: Add test cases.
  18. }
  19. for _, tt := range tests {
  20. t.Run(tt.name, func(t *testing.T) {
  21. if got := keyArc(tt.args.aid); got != tt.want {
  22. t.Errorf("keyArc() = %v, want %v", got, tt.want)
  23. }
  24. })
  25. }
  26. }
  27. func Test_keyStat(t *testing.T) {
  28. type args struct {
  29. aid int64
  30. }
  31. tests := []struct {
  32. name string
  33. args args
  34. want string
  35. }{
  36. // TODO: Add test cases.
  37. }
  38. for _, tt := range tests {
  39. t.Run(tt.name, func(t *testing.T) {
  40. if got := keyStat(tt.args.aid); got != tt.want {
  41. t.Errorf("keyStat() = %v, want %v", got, tt.want)
  42. }
  43. })
  44. }
  45. }
  46. func TestDao_arcsCache(t *testing.T) {
  47. type args struct {
  48. c context.Context
  49. aids []int64
  50. }
  51. tests := []struct {
  52. name string
  53. d *Dao
  54. args args
  55. wantCached map[int64]*api.Arc
  56. wantMissed []int64
  57. wantErr bool
  58. }{
  59. // TODO: Add test cases.
  60. }
  61. for _, tt := range tests {
  62. t.Run(tt.name, func(t *testing.T) {
  63. gotCached, gotMissed, err := tt.d.arcsCache(tt.args.c, tt.args.aids)
  64. if (err != nil) != tt.wantErr {
  65. t.Errorf("Dao.arcsCache() error = %v, wantErr %v", err, tt.wantErr)
  66. return
  67. }
  68. if !reflect.DeepEqual(gotCached, tt.wantCached) {
  69. t.Errorf("Dao.arcsCache() gotCached = %v, want %v", gotCached, tt.wantCached)
  70. }
  71. if !reflect.DeepEqual(gotMissed, tt.wantMissed) {
  72. t.Errorf("Dao.arcsCache() gotMissed = %v, want %v", gotMissed, tt.wantMissed)
  73. }
  74. })
  75. }
  76. }
  77. func TestDao_statsCache(t *testing.T) {
  78. type args struct {
  79. c context.Context
  80. aids []int64
  81. }
  82. tests := []struct {
  83. name string
  84. d *Dao
  85. args args
  86. wantCached map[int64]*api.Stat
  87. wantMissed []int64
  88. wantErr bool
  89. }{
  90. // TODO: Add test cases.
  91. }
  92. for _, tt := range tests {
  93. t.Run(tt.name, func(t *testing.T) {
  94. gotCached, gotMissed, err := tt.d.statsCache(tt.args.c, tt.args.aids)
  95. if (err != nil) != tt.wantErr {
  96. t.Errorf("Dao.statsCache() error = %v, wantErr %v", err, tt.wantErr)
  97. return
  98. }
  99. if !reflect.DeepEqual(gotCached, tt.wantCached) {
  100. t.Errorf("Dao.statsCache() gotCached = %v, want %v", gotCached, tt.wantCached)
  101. }
  102. if !reflect.DeepEqual(gotMissed, tt.wantMissed) {
  103. t.Errorf("Dao.statsCache() gotMissed = %v, want %v", gotMissed, tt.wantMissed)
  104. }
  105. })
  106. }
  107. }
  108. func TestDao_avWithStCaches(t *testing.T) {
  109. type args struct {
  110. c context.Context
  111. aids []int64
  112. }
  113. tests := []struct {
  114. name string
  115. d *Dao
  116. args args
  117. wantCached map[int64]*api.Arc
  118. wantAvMissed []int64
  119. wantStMissed []int64
  120. wantErr bool
  121. }{
  122. // TODO: Add test cases.
  123. }
  124. for _, tt := range tests {
  125. t.Run(tt.name, func(t *testing.T) {
  126. gotCached, gotAvMissed, gotStMissed, err := tt.d.avWithStCaches(tt.args.c, tt.args.aids)
  127. if (err != nil) != tt.wantErr {
  128. t.Errorf("Dao.avWithStCaches() error = %v, wantErr %v", err, tt.wantErr)
  129. return
  130. }
  131. if !reflect.DeepEqual(gotCached, tt.wantCached) {
  132. t.Errorf("Dao.avWithStCaches() gotCached = %v, want %v", gotCached, tt.wantCached)
  133. }
  134. if !reflect.DeepEqual(gotAvMissed, tt.wantAvMissed) {
  135. t.Errorf("Dao.avWithStCaches() gotAvMissed = %v, want %v", gotAvMissed, tt.wantAvMissed)
  136. }
  137. if !reflect.DeepEqual(gotStMissed, tt.wantStMissed) {
  138. t.Errorf("Dao.avWithStCaches() gotStMissed = %v, want %v", gotStMissed, tt.wantStMissed)
  139. }
  140. })
  141. }
  142. }