555 lines
13 KiB
Go
555 lines
13 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/plugin/soft_delete"
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestApprovalOA_BuildResContent(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
a *Approval
|
|
request *approval.CreateRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
oa.BuildResContent(tt.args.a, tt.args.request)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_DeleteApproval(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
p *Approval
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.DeleteApproval(tt.args.p); (err != nil) != tt.wantErr {
|
|
t.Errorf("DeleteApproval() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_GetApproval(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
id uint64
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want *Approval
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
got, err := oa.GetApproval(tt.args.id)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("GetApproval() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("GetApproval() got = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_SaveApprovalContent(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
in *approval.CreateRequest
|
|
a *Approval
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
{
|
|
args: args{
|
|
in: &approval.CreateRequest{
|
|
ID: 0,
|
|
Domain: "",
|
|
Status: 0,
|
|
Type: "",
|
|
SubmitterID: 40,
|
|
SubmitterName: "超级管理员",
|
|
CopyUsers: nil,
|
|
Content: "",
|
|
Reply: "",
|
|
CanView: false,
|
|
ApprovalUsers: nil,
|
|
CanApproval: false,
|
|
WorkFlows: nil,
|
|
AllStatus: 0,
|
|
NowUserId: 0,
|
|
NowUserName: "",
|
|
Level: 0,
|
|
NowLevel: 0,
|
|
CreatedAt: "",
|
|
CustomizeInfo: nil,
|
|
IsCustom: 0,
|
|
TypeName: "",
|
|
GroupName: "",
|
|
BundlePayPrice: nil,
|
|
ApprovalOA: nil,
|
|
FinancialForm: nil,
|
|
},
|
|
a: &Approval{
|
|
SubmitterID: 40,
|
|
Status: 0,
|
|
SubmitterName: "",
|
|
CopyUsers: nil,
|
|
ApprovalUsers: nil,
|
|
Type: "",
|
|
Level: 0,
|
|
NowLevel: 0,
|
|
NowUserId: 0,
|
|
NowUserName: "",
|
|
Content: "",
|
|
ValueJson: nil,
|
|
Reply: "",
|
|
Domain: nil,
|
|
Show: nil,
|
|
ApprovalType: nil,
|
|
Work: nil,
|
|
Bundle: nil,
|
|
Exhibition: nil,
|
|
BundlePayPrice: nil,
|
|
ExhibitionReward: nil,
|
|
ApprovalWorkFlows: nil,
|
|
ApprovalOA: nil,
|
|
FinancialForm: nil,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.SaveApprovalContent(tt.args.in, tt.args.a); (err != nil) != tt.wantErr {
|
|
t.Errorf("SaveApprovalContent() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_TableName(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
want string
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if got := oa.TableName(); got != tt.want {
|
|
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_UpdateApprovalContent(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
in *approval.CreateRequest
|
|
a *Approval
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.UpdateApprovalContent(tt.args.in, tt.args.a); (err != nil) != tt.wantErr {
|
|
t.Errorf("UpdateApprovalContent() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_addOtherInfoToModel(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
in *approval.CreateRequest
|
|
a *Approval
|
|
approvalOA *ApprovalOA
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.addOtherInfoToModel(tt.args.in, tt.args.a, tt.args.approvalOA); (err != nil) != tt.wantErr {
|
|
t.Errorf("addOtherInfoToModel() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_addOtherInfoToRpc(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
a *Approval
|
|
in *approval.CreateRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.addOtherInfoToRpc(tt.args.a, tt.args.in); (err != nil) != tt.wantErr {
|
|
t.Errorf("addOtherInfoToRpc() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_copyOAToModel(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
in *approval.CreateRequest
|
|
a *Approval
|
|
}
|
|
|
|
arg := args{}
|
|
leave := Leave{}
|
|
leave.ActionTime := make([])
|
|
arg.in.ApprovalOA.Leave =
|
|
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantApprovalOA *ApprovalOA
|
|
wantErr bool
|
|
}{
|
|
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
gotApprovalOA, err := oa.copyOAToModel(tt.args.in, tt.args.a)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("copyOAToModel() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(gotApprovalOA, tt.wantApprovalOA) {
|
|
t.Errorf("copyOAToModel() gotApprovalOA = %v, want %v", gotApprovalOA, tt.wantApprovalOA)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestApprovalOA_copyOAToRpc(t *testing.T) {
|
|
type fields struct {
|
|
ID uint64
|
|
DeletedAt soft_delete.DeletedAt
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
ApprovalID uint64
|
|
LeaveApply *LeaveApply
|
|
OutWork *OutWorkApply
|
|
MakeUp *MakeUpApply
|
|
Turnover *TurnoverApply
|
|
OverTime *OverTimeApply
|
|
Leave *Leave
|
|
}
|
|
type args struct {
|
|
a *Approval
|
|
in *approval.CreateRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
oa := &ApprovalOA{
|
|
ID: tt.fields.ID,
|
|
DeletedAt: tt.fields.DeletedAt,
|
|
CreatedAt: tt.fields.CreatedAt,
|
|
UpdatedAt: tt.fields.UpdatedAt,
|
|
ApprovalID: tt.fields.ApprovalID,
|
|
LeaveApply: tt.fields.LeaveApply,
|
|
OutWork: tt.fields.OutWork,
|
|
MakeUp: tt.fields.MakeUp,
|
|
Turnover: tt.fields.Turnover,
|
|
OverTime: tt.fields.OverTime,
|
|
Leave: tt.fields.Leave,
|
|
}
|
|
if err := oa.copyOAToRpc(tt.args.a, tt.args.in); (err != nil) != tt.wantErr {
|
|
t.Errorf("copyOAToRpc() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|