package server import ( "cfTest/cloudflareApi/dns" "context" "reflect" "testing" ) func TestDnsServer_List(t *testing.T) { type fields struct { UnimplementedDnsCloudflareServer dns.UnimplementedDnsCloudflareServer } type args struct { ctx context.Context request *dns.ListRequest } tests := []struct { name string fields fields args args want *dns.DnsRecordList wantErr bool }{ { name: "成功测试", fields: fields{ UnimplementedDnsCloudflareServer: dns.UnimplementedDnsCloudflareServer{}, }, args: args{ ctx: nil, request: &dns.ListRequest{ ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5", ApiEmail: "ll@centcloud.net", ZoneId: "a6383cfb80012436f261793522e811e8", }, }, want: nil, wantErr: false, }, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { d := DnsServer{ UnimplementedDnsCloudflareServer: tt.fields.UnimplementedDnsCloudflareServer, } got, err := d.List(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("List() error = %v, wantErr %v", err, tt.wantErr) return } //if !reflect.DeepEqual(got, tt.want) { // t.Errorf("List() got = %v, want %v", got, tt.want) //} print(got) }) } } func TestDnsServer_Create(t *testing.T) { type fields struct { UnimplementedDnsCloudflareServer dns.UnimplementedDnsCloudflareServer } type args struct { ctx context.Context request *dns.DnsRecordRequest } tests := []struct { name string fields fields args args want *dns.DnsRecord wantErr bool }{ { name: "测试1", fields: fields{ UnimplementedDnsCloudflareServer: dns.UnimplementedDnsCloudflareServer{}, }, args: args{ ctx: nil, request: &dns.DnsRecordRequest{ ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5", ApiEmail: "ll@centcloud.net", ZoneId: "a6383cfb80012436f261793522e811e8", DnsRecord: &dns.DnsRecord{ Id: "", Name: "recordTest1", Type: "A", Content: "11.23.11.23", Ttl: 1, ZoneId: "", ZoneName: "", Proxied: true, }, }, }, want: nil, wantErr: false, }, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { d := DnsServer{ UnimplementedDnsCloudflareServer: tt.fields.UnimplementedDnsCloudflareServer, } got, err := d.Create(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("Create() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("Create() got = %v, want %v", got, tt.want) } }) } } func TestDnsServer_Delete(t *testing.T) { type fields struct { UnimplementedDnsCloudflareServer dns.UnimplementedDnsCloudflareServer } type args struct { ctx context.Context request *dns.DeleteRequest } tests := []struct { name string fields fields args args want *dns.Empty wantErr bool }{ { name: "1", fields: fields{}, args: args{ ctx: nil, request: &dns.DeleteRequest{ ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5", ApiEmail: "ll@centcloud.net", ZoneId: "a6383cfb80012436f261793522e811e8", Id: "f406d1b89b9dc9897853e4771e9e2796", }, }, want: nil, wantErr: false, }, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { d := DnsServer{ UnimplementedDnsCloudflareServer: tt.fields.UnimplementedDnsCloudflareServer, } got, err := d.Delete(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("Delete() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("Delete() got = %v, want %v", got, tt.want) } }) } } func TestDnsServer_Update(t *testing.T) { type fields struct { UnimplementedDnsCloudflareServer dns.UnimplementedDnsCloudflareServer } type args struct { ctx context.Context request *dns.DnsRecordRequest } tests := []struct { name string fields fields args args want *dns.Empty wantErr bool }{ { name: "1", fields: fields{ UnimplementedDnsCloudflareServer: dns.UnimplementedDnsCloudflareServer{}, }, args: args{ ctx: nil, request: &dns.DnsRecordRequest{ ApiKey: "2cc87f6213a4c40e5a90c8dced3c9c577eda5", ApiEmail: "ll@centcloud.net", ZoneId: "a6383cfb80012436f261793522e811e8", DnsRecord: &dns.DnsRecord{ Id: "f406d1b89b9dc9897853e4771e9e2796", Name: "recordtest2", Type: "A", Content: "23.11.23.11", Ttl: 1, ZoneId: "", ZoneName: "", Proxied: true, }, }, }, want: nil, wantErr: false, }, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { d := DnsServer{ UnimplementedDnsCloudflareServer: tt.fields.UnimplementedDnsCloudflareServer, } got, err := d.Update(tt.args.ctx, tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("Update() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("Update() got = %v, want %v", got, tt.want) } }) } }