package external

import (
	"testing"
)

func TestIRedMail_login(t *testing.T) {
	type fields struct {
		Username string
		Password string
	}
	tests := []struct {
		name    string
		fields  fields
		want    string
		wantErr bool
	}{
		// TODO: Add test cases.
		{fields: fields{Username: "postmaster@fontree.cn", Password: "Zaq12wsx"}},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			m := &IRedMail{
				Username: tt.fields.Username,
				Password: tt.fields.Password,
			}
			err := m.login()
			if (err != nil) != tt.wantErr {
				t.Errorf("login() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
		})
	}
}

func TestIRedMail_CreateMailAccount(t *testing.T) {

	type fields struct {
		Username   string
		Password   string
		Domain     string
		iredCookie *iredCookie
	}
	type args struct {
		new CreateAccountInfo
	}
	tests := []struct {
		name    string
		fields  fields
		args    args
		wantErr bool
	}{
		// TODO: Add test cases.
		{args: args{new: CreateAccountInfo{Username: "gengyang", Password: "Aa.123456", Cn: "耿阳"}}, fields: fields{
			Username: "postmaster@fontree.cn",
			Password: "Zaq12wsx",
			Domain:   "fontree.cn",
		}},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			m := &IRedMail{
				Username:   tt.fields.Username,
				Password:   tt.fields.Password,
				Domain:     tt.fields.Domain,
				iredCookie: tt.fields.iredCookie,
			}
			err := m.CreateMailAccount(tt.args.new)
			if (err != nil) != tt.wantErr {
				t.Errorf("CreateMailAccount() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
		})
	}
}
