CertificateCloudflareServer_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package server
  2. import (
  3. cert "cfTest/cloudflareApi/certificate"
  4. "context"
  5. "fmt"
  6. "reflect"
  7. "testing"
  8. )
  9. func TestCertificateServer_ListZoneCertificates(t *testing.T) {
  10. type fields struct {
  11. UnimplementedCertificateCloudflareServer cert.UnimplementedCertificateCloudflareServer
  12. }
  13. type args struct {
  14. ctx context.Context
  15. requestCloudflare *cert.ListZoneCertificatesRequestCloudflare
  16. }
  17. tests := []struct {
  18. name string
  19. fields fields
  20. args args
  21. want *cert.ListZoneCertificatesReplyCloudflare
  22. wantErr bool
  23. }{
  24. // TODO: Add test cases.
  25. {
  26. name: "测试用例1",
  27. fields: fields{
  28. UnimplementedCertificateCloudflareServer: cert.UnimplementedCertificateCloudflareServer{},
  29. },
  30. args: args{
  31. requestCloudflare: &cert.ListZoneCertificatesRequestCloudflare{
  32. ApiKey: "2046cc148e3d2cf6f7b715a7b62327f0f4189",
  33. ApiEmail: "support03@cengcloud.com",
  34. ZoneId: "e7d8af14a09356edfe8096617c3af187",
  35. },
  36. },
  37. wantErr: false,
  38. },
  39. }
  40. for _, tt := range tests {
  41. t.Run(tt.name, func(t *testing.T) {
  42. s := &CertificateServer{
  43. UnimplementedCertificateCloudflareServer: tt.fields.UnimplementedCertificateCloudflareServer,
  44. }
  45. got, err := s.ListZoneCertificates(tt.args.ctx, tt.args.requestCloudflare)
  46. fmt.Println(got)
  47. if (err != nil) != tt.wantErr {
  48. t.Errorf("ListZoneCertificates() error = %v, wantErr %v", err, tt.wantErr)
  49. return
  50. }
  51. if !reflect.DeepEqual(got, tt.want) {
  52. t.Errorf("ListZoneCertificates() got = %v, want %v", got, tt.want)
  53. }
  54. })
  55. }
  56. }