package server import ( "cfTest/cloudflareApi/zone" "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/samber/lo" "log" "reflect" "testing" "time" ) // func TestCreateRuleSet(t *testing.T) { // type args struct { // zoneID string // rulesetPhase string // ruleset cloudflare.Ruleset // } // // var ( // True = true // CONST604800 = uint(604800) // ) // // tests := []struct { // name string // args args // want interface{} // wantErr bool // }{ // { // name: "Test1", // args: args{ // zoneID: "e29551894461bf16e43a113e5ab09ed3", // rulesetPhase: "http_request_cache_settings", // ruleset: cloudflare.Ruleset{ // Rules: []cloudflare.RulesetRule{ // { // Expression: "(starts_with(http.request.uri.path, \"/\"))", // Enabled: true, // Description: "test1", // Action: "set_cache_settings", // ActionParameters: &cloudflare.RulesetRuleActionParameters{ // Cache: &True, // CacheKey: &cloudflare.RulesetRuleActionParametersCacheKey{ // CustomKey: &cloudflare.RulesetRuleActionParametersCustomKey{ // Query: &cloudflare.RulesetRuleActionParametersCustomKeyQuery{ // Exclude: &cloudflare.RulesetRuleActionParametersCustomKeyList{ // List: []string{ // "abc", // }, // All: false, // }, // }, // }, // }, // EdgeTTL: &cloudflare.RulesetRuleActionParametersEdgeTTL{ // Mode: "override_origin", // Default: &CONST604800, // }, // }, // }, // }, // }, // }, // want: nil, // wantErr: false, // }, // } // for _, tt := range tests { // t.Run(tt.name, func(t *testing.T) { // got, err := UpdateRuleSet("", "", tt.args.zoneID, tt.args.rulesetPhase, tt.args.ruleset) // if (err != nil) != tt.wantErr { // t.Errorf("UpdateRuleSet() error = %v, wantErr %v", err, tt.wantErr) // return // } // if !reflect.DeepEqual(got, tt.want) { // t.Errorf("UpdateRuleSet() got = %v, want %v", got, tt.want) // } // }) // } // } // // func newUint32(a uint32) *uint32 { // return &a // } // // func newStr(a string) *string { // return &a // } var ( apiKey = "2cc87f6213a4c40e5a90c8dced3c9c577eda5" apiEmail = "ll@centcloud.net" ) //func TestUpdatePageRule(t *testing.T) { // // type args struct { // apiKey string // apiEmail string // zoneID string // rule *zone.Rule // } // tests := []struct { // name string // args args // want *cloudflare.PageRule // wantErr bool // }{ // { // name: "测试1", // args: args{ // apiKey: apiKey, // apiEmail: apiEmail, // zoneID: "e29551894461bf16e43a113e5ab09ed3", // rule: &zone.Rule{ // Expression: "www.1011test5.com.cdn.sensordb.site/*\n", // Ttl: newUint32(18000), // QueryArgsType: newStr("ExcludeAll"), // QueryArgs: []string{"qwe12", "78u9hi"}, // OriginHost: newStr("www.baidu.com"), // OriginPath: nil, // OriginProtocol: newUint32(80), // RequestHeader: nil, // ResponseHeader: nil, // }, // }, // want: nil, // wantErr: false, // }, // // TODO: Add test cases. // } // for _, tt := range tests { // t.Run(tt.name, func(t *testing.T) { // got, err := UpdatePageRule(tt.args.apiKey, tt.args.apiEmail, tt.args.zoneID, tt.args.rule) // if (err != nil) != tt.wantErr { // t.Errorf("UpdatePageRule() error = %v, wantErr %v", err, tt.wantErr) // return // } // print("%v", got) // //if !reflect.DeepEqual(got, tt.want) { // // t.Errorf("UpdatePageRule() got = %v, want %v", got, tt.want) // //} // }) // } //} func TestZoneServer_GetRuleSet(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.GetRuleSetRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleList wantErr bool }{ { name: "测试1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.GetRuleSetRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5801a8cbe2fdfd6c53413d0eef164d23", Phase: zone.Phase_http_request_cache_settings, }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.GetRuleSet(tt.args.ctx, tt.args.requestCloudflare) fmt.Println(got) if (err != nil) != tt.wantErr { t.Errorf("GetRuleSet() error = %v, wantErr %v", err, tt.wantErr) return } log.Print(got) //if !reflect.DeepEqual(got, tt.want) { // t.Errorf("GetRuleSet() got = %v, want %v", got, tt.want) //} }) } } func TestZoneServer_UpdateRuleSet(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.UpdateRuleSetRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleList wantErr bool }{ { name: "测试1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: nil, requestCloudflare: &zone.UpdateRuleSetRequestCloudflare{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "e29551894461bf16e43a113e5ab09ed3", Phase: zone.Phase_http_request_transform, Rules: []*zone.Rule{ { Expression: "(http.request.uri.path contains \"www.1011test5.com.cdn.sensordb.site/\")", OriginPath: lo.ToPtr[string]("www.baidu.com"), RequestHeader: nil, ResponseHeader: nil, }, }, }, }, want: nil, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.UpdateRuleSet(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("UpdateRuleSet() error = %v, wantErr %v", err, tt.wantErr) return } log.Print(got) //if !reflect.DeepEqual(got, tt.want) { // t.Errorf("UpdateRuleSet() got = %v, want %v", got, tt.want) //} }) } } func TestZoneServer_GetArgoSetting(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.IdRequest } tests := []struct { name string fields fields args args want *zone.ArgoSetting wantErr bool }{ { name: "test1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.IdRequest{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "f7eefa29114db32ab14397bdd5048ec8", }, }, want: &zone.ArgoSetting{Enabled: true}, wantErr: false, }, { name: "test1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.IdRequest{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "f7eefa29114db32ab14397bdd5048ec8", }, }, want: &zone.ArgoSetting{Enabled: false}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.GetArgoSetting(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("GetArgoSetting() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("GetArgoSetting() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_UpdateArgoSetting(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.UpdateArgoRequestCloudflare } tests := []struct { name string fields fields args args want *zone.ArgoSetting wantErr bool }{ { name: "test1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.UpdateArgoRequestCloudflare{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "f7eefa29114db32ab14397bdd5048ec8", ArgoSetting: &zone.ArgoSetting{Enabled: false}, }, }, want: &zone.ArgoSetting{Enabled: false}, wantErr: false, }, { name: "test1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.UpdateArgoRequestCloudflare{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "f7eefa29114db32ab14397bdd5048ec8", ArgoSetting: &zone.ArgoSetting{Enabled: true}, }, }, want: &zone.ArgoSetting{Enabled: true}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.UpdateArgoSetting(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("UpdateArgoSetting() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("UpdateArgoSetting() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_GetArgoSettingSubscription(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context request *zone.IdRequest } tests := []struct { name string fields fields args args want *zone.ArgoSetting wantErr bool }{ { name: "启用测试", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: nil, request: &zone.IdRequest{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "f7eefa29114db32ab14397bdd5048ec8", }, }, want: &zone.ArgoSetting{Enabled: true}, wantErr: false, }, { name: "未启用测试", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: nil, request: &zone.IdRequest{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "6d89e53e52a08fc51b99628ff546c7fb", }, }, want: &zone.ArgoSetting{Enabled: false}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.GetArgoSettingSubscription(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("GetArgoSettingSubscription() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("GetArgoSettingSubscription() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_CreateArgoSettingSubscription(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context request *zone.IdRequest } tests := []struct { name string fields fields args args want *zone.ArgoSetting wantErr bool }{ { name: "测试", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: nil, request: &zone.IdRequest{ ApiKey: apiKey, ApiEmail: apiEmail, ZoneId: "7a25de4f4ea643e99c66e84e7498ccc6", }, }, want: &zone.ArgoSetting{Enabled: true}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.CreateArgoSettingSubscription(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("CreateArgoSettingSubscription() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("CreateArgoSettingSubscription() got = %v, want %v", got, tt.want) } }) } } func TestCreateZone(t *testing.T) { api, err := cloudflare.New("d2589c4f617b0493357ae187a7b4518171d07", "shiqi@centcloud.net") if err != nil { t.Fatal(err) } ctx := context.Background() account, r, err := api.Account(ctx, "b9145a83318cae896ad9b23bdf1681a5") if err != nil { t.Fatal(err) } t.Logf("Account Info:%+v", r) createZone, err := api.CreateZone(ctx, "cf004.shiqi.website", false, account, "partial") if err != nil { t.Fatal(err) } t.Logf("createZone: %+v", createZone) time.Sleep(time.Second) zoneId := createZone.ID err = api.ZoneSetPlan(ctx, zoneId, "PARTNERS_ENT") if err != nil { t.Fatal(err) } } func TestZoneServer_CreateZone(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.CreateZoneRequestCloudflare } tests := []struct { name string fields fields args args want *zone.CreateZoneReplyCloudflare wantErr bool }{ { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.CreateZoneRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", AccountId: "b9145a83318cae896ad9b23bdf1681a5", Domain: "cf005.shiqi.website", }, }, want: nil, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.CreateZone(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("CreateZone() error = %v, wantErr %v", err, tt.wantErr) return } t.Logf("CreateZone() got = %v", got) }) } } func TestZoneServer_SetZonePlan(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.SetZonePlanRequestCloudflare } tests := []struct { name string fields fields args args want *zone.SetZonePlanReplyCloudflare wantErr bool }{ { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ ctx: context.Background(), requestCloudflare: &zone.SetZonePlanRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "19e7978bb9292fe11d3c75ff39f87685", ZonePlan: "PARTNERS_ENT", }, }, want: &zone.SetZonePlanReplyCloudflare{Success: true}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.SetZonePlan(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("SetZonePlan() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("SetZonePlan() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_CreateZoneRuleSet(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.CreateZoneRuleSetRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleSet wantErr bool }{ { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.CreateZoneRuleSetRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5801a8cbe2fdfd6c53413d0eef164d23", RuleSet: &zone.RuleSet{ Name: "rule1", Kind: "zone", Phase: zone.Phase_http_request_cache_settings, }, Rules: []*zone.Rule{ { Expression: "(http.request.uri.path contains \"shiqi.website/\")", Ttl: lo.ToPtr[uint32](604800), QueryArgsType: lo.ToPtr[string]("Include"), QueryArgs: []string{"qwe12", "78u9hi"}, }, }, }, }, wantErr: false, }, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.CreateZoneRuleSet(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("CreateZoneRuleSet() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("CreateZoneRuleSet() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_ListZoneRuleSets(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.ListZoneRuleSetsRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleSetList wantErr bool }{ { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.ListZoneRuleSetsRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5801a8cbe2fdfd6c53413d0eef164d23", }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.ListZoneRuleSets(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("ListZoneRuleSets() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("ListZoneRuleSets() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_UpdateRuleSet1(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.UpdateRuleSetRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleList wantErr bool }{ // TODO: Add test cases. { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.UpdateRuleSetRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5ee6daeeecf5c088c7517afa95c50739", Phase: zone.Phase_http_request_cache_settings, Rules: []*zone.Rule{ { Expression: "(http.request.uri.path contains \"shiqi.website/\")", Ttl: lo.ToPtr[uint32](604800 / 7), QueryArgsType: lo.ToPtr[string]("Include"), QueryArgs: []string{"qwe12", "78u9hi"}, }, { Expression: "(http.request.uri.path contains \"shiqi.website/\")", Ttl: lo.ToPtr[uint32](604800), QueryArgsType: lo.ToPtr[string]("Include"), QueryArgs: []string{"qwe12"}, }, }, }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.UpdateRuleSet(tt.args.ctx, tt.args.requestCloudflare) fmt.Println(got, err) if (err != nil) != tt.wantErr { t.Errorf("UpdateRuleSet() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("UpdateRuleSet() got = %v, want %v", got, tt.want) } }) } } //RuleSetId = 12371a315d344f719382becef2577d4c func TestZoneServer_UpdateRuleSetByRuleSetId(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.UpdateRuleSetByRuleSetIdRequestCloudflare } tests := []struct { name string fields fields args args want *zone.RuleSet wantErr bool }{ // TODO: Add test cases. { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.UpdateRuleSetByRuleSetIdRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "f62e1be1fea702904da5ead2d1dc15de", RuleSetId: "12371a315d344f719382becef2577d4c", Phase: zone.Phase_http_request_cache_settings, Rules: []*zone.Rule{ { Expression: "(http.request.uri.path contains \"shi.website/\")", Ttl: lo.ToPtr[uint32](604800), QueryArgsType: lo.ToPtr[string]("ExcludeAll"), QueryArgs: []string{"qwe12", "78u9hi"}, }, }, }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.UpdateRuleSetByRuleSetId(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("UpdateRuleSetByRuleSetId() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("UpdateRuleSetByRuleSetId() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_DeleteZoneRuleSet(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.DeleteZoneRuleSetRequestCloudflare } tests := []struct { name string fields fields args args want *zone.DeleteZoneRuleSetReplyCloudflare wantErr bool }{ { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.DeleteZoneRuleSetRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5801a8cbe2fdfd6c53413d0eef164d23", RuleSetId: "c9e073e5447c461da612be101d64ec04", }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.DeleteZoneRuleSet(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("DeleteZoneRuleSet() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("DeleteZoneRuleSet() got = %v, want %v", got, tt.want) } }) } } func TestZoneServer_UpdateAlwaysUseHttps(t *testing.T) { type fields struct { UnimplementedZoneCloudflareServer zone.UnimplementedZoneCloudflareServer } type args struct { ctx context.Context requestCloudflare *zone.UpdateAlwaysUseHttpsRequestCloudflare } tests := []struct { name string fields fields args args want *zone.UpdateAlwaysUseHttpsReplyCloudflare wantErr bool }{ // TODO: Add test cases. { name: "测试用例1", fields: fields{ UnimplementedZoneCloudflareServer: zone.UnimplementedZoneCloudflareServer{}, }, args: args{ requestCloudflare: &zone.UpdateAlwaysUseHttpsRequestCloudflare{ ApiKey: "d2589c4f617b0493357ae187a7b4518171d07", ApiEmail: "shiqi@centcloud.net", ZoneId: "5801a8cbe2fdfd6c53413d0eef164d23", Enabled: false, }, }, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { s := &ZoneServer{ UnimplementedZoneCloudflareServer: tt.fields.UnimplementedZoneCloudflareServer, } got, err := s.UpdateAlwaysUseHttps(tt.args.ctx, tt.args.requestCloudflare) if (err != nil) != tt.wantErr { t.Errorf("UpdateAlwaysUseHttps() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("UpdateAlwaysUseHttps() got = %v, want %v", got, tt.want) } }) } }