LoadBalancerCloudflareServer_test.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. package server
  2. import (
  3. "cfTest/cloudflareApi/loadBalancer"
  4. "context"
  5. "reflect"
  6. "testing"
  7. )
  8. func TestLoadBalancerServer_Create(t *testing.T) {
  9. type fields struct {
  10. UnimplementedLoadBalancerCloudflareServer loadBalancer.UnimplementedLoadBalancerCloudflareServer
  11. }
  12. type args struct {
  13. ctx context.Context
  14. request *loadBalancer.LoadBalancerRequest
  15. }
  16. tests := []struct {
  17. name string
  18. fields fields
  19. args args
  20. want *loadBalancer.LoadBalancer
  21. wantErr bool
  22. }{
  23. {
  24. name: "1",
  25. fields: fields{},
  26. args: args{
  27. ctx: nil,
  28. request: &loadBalancer.LoadBalancerRequest{
  29. ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5",
  30. ApiEmail: "ll@centcloud.net",
  31. ZoneId: "a6383cfb80012436f261793522e811e8",
  32. LoadBalancer: &loadBalancer.LoadBalancer{
  33. Id: "",
  34. Name: "test.test1121.com.cdn.sensordb.site",
  35. DefaultPools: []string{"6c946466b3d38323661808d5655f3423"},
  36. FallbackPool: "6c946466b3d38323661808d5655f3423",
  37. Proxied: true,
  38. },
  39. },
  40. },
  41. want: nil,
  42. wantErr: false,
  43. },
  44. // TODO: Add test cases.
  45. }
  46. for _, tt := range tests {
  47. t.Run(tt.name, func(t *testing.T) {
  48. d := LoadBalancerServer{
  49. UnimplementedLoadBalancerCloudflareServer: tt.fields.UnimplementedLoadBalancerCloudflareServer,
  50. }
  51. got, err := d.Create(tt.args.ctx, tt.args.request)
  52. if (err != nil) != tt.wantErr {
  53. t.Errorf("Create() error = %v, wantErr %v", err, tt.wantErr)
  54. return
  55. }
  56. if !reflect.DeepEqual(got, tt.want) {
  57. t.Errorf("Create() got = %v, want %v", got, tt.want)
  58. }
  59. })
  60. }
  61. }
  62. func TestLoadBalancerServer_Delete(t *testing.T) {
  63. type fields struct {
  64. UnimplementedLoadBalancerCloudflareServer loadBalancer.UnimplementedLoadBalancerCloudflareServer
  65. }
  66. type args struct {
  67. ctx context.Context
  68. request *loadBalancer.DeleteRequest
  69. }
  70. tests := []struct {
  71. name string
  72. fields fields
  73. args args
  74. want *loadBalancer.Empty
  75. wantErr bool
  76. }{
  77. {
  78. name: "1",
  79. fields: fields{},
  80. args: args{
  81. ctx: nil,
  82. request: &loadBalancer.DeleteRequest{
  83. ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5",
  84. ApiEmail: "ll@centcloud.net",
  85. ZoneId: "a6383cfb80012436f261793522e811e8",
  86. Id: "0fb7f62b06de8b085e0b29183a0b365c",
  87. },
  88. },
  89. want: nil,
  90. wantErr: false,
  91. },
  92. // TODO: Add test cases.
  93. }
  94. for _, tt := range tests {
  95. t.Run(tt.name, func(t *testing.T) {
  96. d := LoadBalancerServer{
  97. UnimplementedLoadBalancerCloudflareServer: tt.fields.UnimplementedLoadBalancerCloudflareServer,
  98. }
  99. got, err := d.Delete(tt.args.ctx, tt.args.request)
  100. if (err != nil) != tt.wantErr {
  101. t.Errorf("Delete() error = %v, wantErr %v", err, tt.wantErr)
  102. return
  103. }
  104. if !reflect.DeepEqual(got, tt.want) {
  105. t.Errorf("Delete() got = %v, want %v", got, tt.want)
  106. }
  107. })
  108. }
  109. }
  110. func TestLoadBalancerServer_List(t *testing.T) {
  111. type fields struct {
  112. UnimplementedLoadBalancerCloudflareServer loadBalancer.UnimplementedLoadBalancerCloudflareServer
  113. }
  114. type args struct {
  115. ctx context.Context
  116. request *loadBalancer.ListRequest
  117. }
  118. tests := []struct {
  119. name string
  120. fields fields
  121. args args
  122. want *loadBalancer.LoadBalancerList
  123. wantErr bool
  124. }{
  125. {
  126. name: "1",
  127. fields: fields{},
  128. args: args{
  129. ctx: nil,
  130. request: &loadBalancer.ListRequest{
  131. ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5",
  132. ApiEmail: "ll@centcloud.net",
  133. ZoneId: "a6383cfb80012436f261793522e811e8",
  134. },
  135. },
  136. want: nil,
  137. wantErr: false,
  138. },
  139. // TODO: Add test cases.
  140. }
  141. for _, tt := range tests {
  142. t.Run(tt.name, func(t *testing.T) {
  143. d := LoadBalancerServer{
  144. UnimplementedLoadBalancerCloudflareServer: tt.fields.UnimplementedLoadBalancerCloudflareServer,
  145. }
  146. got, err := d.List(tt.args.ctx, tt.args.request)
  147. if (err != nil) != tt.wantErr {
  148. t.Errorf("List() error = %v, wantErr %v", err, tt.wantErr)
  149. return
  150. }
  151. if !reflect.DeepEqual(got, tt.want) {
  152. t.Errorf("List() got = %v, want %v", got, tt.want)
  153. }
  154. })
  155. }
  156. }
  157. func TestLoadBalancerServer_Update(t *testing.T) {
  158. type fields struct {
  159. UnimplementedLoadBalancerCloudflareServer loadBalancer.UnimplementedLoadBalancerCloudflareServer
  160. }
  161. type args struct {
  162. ctx context.Context
  163. request *loadBalancer.LoadBalancerRequest
  164. }
  165. tests := []struct {
  166. name string
  167. fields fields
  168. args args
  169. want *loadBalancer.LoadBalancer
  170. wantErr bool
  171. }{
  172. {
  173. name: "1",
  174. fields: fields{},
  175. args: args{
  176. ctx: nil,
  177. request: &loadBalancer.LoadBalancerRequest{
  178. ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5",
  179. ApiEmail: "ll@centcloud.net",
  180. ZoneId: "a6383cfb80012436f261793522e811e8",
  181. LoadBalancer: &loadBalancer.LoadBalancer{
  182. Id: "0fb7f62b06de8b085e0b29183a0b365c",
  183. Name: "test2.test1121.com.cdn.sensordb.site",
  184. DefaultPools: []string{
  185. "6c946466b3d38323661808d5655f3423",
  186. },
  187. FallbackPool: "6c946466b3d38323661808d5655f3423",
  188. Proxied: true,
  189. },
  190. },
  191. },
  192. want: nil,
  193. wantErr: false,
  194. },
  195. // TODO: Add test cases.
  196. }
  197. for _, tt := range tests {
  198. t.Run(tt.name, func(t *testing.T) {
  199. d := LoadBalancerServer{
  200. UnimplementedLoadBalancerCloudflareServer: tt.fields.UnimplementedLoadBalancerCloudflareServer,
  201. }
  202. got, err := d.Update(tt.args.ctx, tt.args.request)
  203. if (err != nil) != tt.wantErr {
  204. t.Errorf("Update() error = %v, wantErr %v", err, tt.wantErr)
  205. return
  206. }
  207. if !reflect.DeepEqual(got, tt.want) {
  208. t.Errorf("Update() got = %v, want %v", got, tt.want)
  209. }
  210. })
  211. }
  212. }