V2
This commit is contained in:
@ -407,6 +407,150 @@ func TestMapperImpl_PlanDayDsToApi(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapperImpl_PlanWeekApiToDs(t *testing.T) {
|
||||
date, _ := time.Parse("2006-01-02", "2022-02-18")
|
||||
items, _ := json.Marshal([]dashapi.PlanWeekItem{
|
||||
{
|
||||
Item: "test1",
|
||||
NumTodo: 3,
|
||||
NumDone: 1,
|
||||
},
|
||||
{
|
||||
Item: "test2",
|
||||
NumTodo: 3,
|
||||
NumDone: 3,
|
||||
}})
|
||||
empty, _ := json.Marshal(nil)
|
||||
|
||||
type args struct {
|
||||
am interface{}
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
mapper MapperImpl
|
||||
args args
|
||||
wantDm interface{}
|
||||
}{
|
||||
{
|
||||
name: "Full Object",
|
||||
mapper: MapperImpl{},
|
||||
args: args{
|
||||
am: dashapi.PlanWeek{
|
||||
Date: "2022-02-18",
|
||||
Items: []dashapi.PlanWeekItem{
|
||||
{
|
||||
Item: "test1",
|
||||
NumTodo: 3,
|
||||
NumDone: 1,
|
||||
},
|
||||
{
|
||||
Item: "test2",
|
||||
NumTodo: 3,
|
||||
NumDone: 3,
|
||||
},
|
||||
}}},
|
||||
wantDm: models.PlanWeek{
|
||||
Date: datatypes.Date(date),
|
||||
Items: datatypes.JSON(items),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Empty Object",
|
||||
mapper: MapperImpl{},
|
||||
args: args{
|
||||
am: dashapi.PlanWeek{
|
||||
Date: "2022-02-18",
|
||||
Items: nil,
|
||||
}},
|
||||
wantDm: models.PlanWeek{
|
||||
Date: datatypes.Date(date),
|
||||
Items: datatypes.JSON(empty),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mapper := MapperImpl{}
|
||||
if gotDm := mapper.PlanWeekApiToDs(tt.args.am); !reflect.DeepEqual(gotDm, tt.wantDm) {
|
||||
t.Errorf("MapperImpl.PlanWeekApiToDs() = %v, want %v", gotDm, tt.wantDm)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// write a test for PlanMonthApiToDs
|
||||
|
||||
func TestMapperImpl_PlanWeekDsToApi(t *testing.T) {
|
||||
date, _ := time.Parse("2006-01-02", "2022-02-18")
|
||||
items, _ := json.Marshal([]dashapi.PlanWeekItem{
|
||||
{
|
||||
Item: "test1",
|
||||
NumTodo: 3,
|
||||
NumDone: 1,
|
||||
},
|
||||
{
|
||||
Item: "test2",
|
||||
NumTodo: 3,
|
||||
NumDone: 3,
|
||||
}})
|
||||
empty, _ := json.Marshal(nil)
|
||||
|
||||
type args struct {
|
||||
dm interface{}
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
mapper MapperImpl
|
||||
args args
|
||||
wantAm interface{}
|
||||
}{
|
||||
{
|
||||
name: "Full Object",
|
||||
mapper: MapperImpl{},
|
||||
args: args{
|
||||
dm: models.PlanWeek{
|
||||
Date: datatypes.Date(date),
|
||||
Items: datatypes.JSON(items),
|
||||
}},
|
||||
wantAm: dashapi.PlanWeek{
|
||||
Date: "2022-02-18",
|
||||
Items: []dashapi.PlanWeekItem{
|
||||
{
|
||||
Item: "test1",
|
||||
NumTodo: 3,
|
||||
NumDone: 1,
|
||||
},
|
||||
{
|
||||
Item: "test2",
|
||||
NumTodo: 3,
|
||||
NumDone: 3,
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Empty Object",
|
||||
mapper: MapperImpl{},
|
||||
args: args{
|
||||
dm: models.PlanWeek{
|
||||
Date: datatypes.Date(date),
|
||||
Items: datatypes.JSON(empty),
|
||||
}},
|
||||
wantAm: dashapi.PlanWeek{
|
||||
Date: "2022-02-18",
|
||||
Items: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mapper := MapperImpl{}
|
||||
if gotAm := mapper.PlanWeekDsToApi(tt.args.dm); !reflect.DeepEqual(gotAm, tt.wantAm) {
|
||||
t.Errorf("MapperImpl.PlanWeekDsToApi() = %v, want %v", gotAm, tt.wantAm)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapperImpl_StringToDate(t *testing.T) {
|
||||
type args struct {
|
||||
dateString string
|
||||
@ -480,3 +624,25 @@ func TestMapperImpl_DateToString(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapperImpl_InboxApiToDs(t *testing.T) {
|
||||
type args struct {
|
||||
am interface{}
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
mapper MapperImpl
|
||||
args args
|
||||
wantDm interface{}
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mapper := MapperImpl{}
|
||||
if gotDm := mapper.InboxApiToDs(tt.args.am); !reflect.DeepEqual(gotDm, tt.wantDm) {
|
||||
t.Errorf("MapperImpl.InboxApiToDs() = %v, want %v", gotDm, tt.wantDm)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user