Skip to content

Commit e4c8f85

Browse files
authored
[fix][backend]: dto conveter of validateMultiPartData (#480)
* fix: error type * chore: ut
1 parent 257bf1a commit e4c8f85

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

backend/modules/evaluation/application/convertor/evaluation_set/evaluation_set.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func UploadAttachmentDetailDO2DTO(do *entity.UploadAttachmentDetail) *app_eval_s
136136
if do == nil {
137137
return nil
138138
}
139-
return &app_eval_set.UploadAttachmentDetail{
139+
dto := &app_eval_set.UploadAttachmentDetail{
140140
ContentType: contentTypeDO2DTO(do.ContentType),
141141
ImagexServiceID: do.ImagexServiceID,
142142
OriginImage: common.ConvertImageDO2DTO(do.OriginImage),
@@ -146,8 +146,11 @@ func UploadAttachmentDetailDO2DTO(do *entity.UploadAttachmentDetail) *app_eval_s
146146
OriginVideo: common.ConvertVideoDO2DTO(do.OriginVideo),
147147
Video: common.ConvertVideoDO2DTO(do.Video),
148148
ErrMsg: do.ErrMsg,
149-
ErrorType: gptr.Of(dataset.ItemErrorType(gptr.Indirect(do.ErrorType))),
150149
}
150+
if do.ErrorType != nil {
151+
dto.ErrorType = gptr.Of(dataset.ItemErrorType(gptr.Indirect(do.ErrorType)))
152+
}
153+
return dto
151154
}
152155

153156
func contentTypeDO2DTO(ct *entity.ContentType) *dataset.ContentType {

backend/modules/evaluation/application/convertor/evaluation_set/evaluation_set_simple_test.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -294,54 +294,45 @@ func TestUploadAttachmentDetailDO2DTO(t *testing.T) {
294294
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentTypeText)},
295295
expected: &app_eval_set.UploadAttachmentDetail{
296296
ContentType: gptr.Of(dataset.ContentType_Text),
297-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
298297
},
299298
},
300299
{
301300
name: "image content type",
302301
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentTypeImage)},
303302
expected: &app_eval_set.UploadAttachmentDetail{
304303
ContentType: gptr.Of(dataset.ContentType_Image),
305-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
306304
},
307305
},
308306
{
309307
name: "audio content type",
310308
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentTypeAudio)},
311309
expected: &app_eval_set.UploadAttachmentDetail{
312310
ContentType: gptr.Of(dataset.ContentType_Audio),
313-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
314311
},
315312
},
316313
{
317314
name: "video content type",
318315
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentTypeVideo)},
319316
expected: &app_eval_set.UploadAttachmentDetail{
320317
ContentType: gptr.Of(dataset.ContentType_Video),
321-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
322318
},
323319
},
324320
{
325321
name: "multipart content type",
326322
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentTypeMultipart)},
327323
expected: &app_eval_set.UploadAttachmentDetail{
328324
ContentType: gptr.Of(dataset.ContentType_MultiPart),
329-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
330325
},
331326
},
332327
{
333-
name: "unknown content type",
334-
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentType("unknown"))},
335-
expected: &app_eval_set.UploadAttachmentDetail{
336-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
337-
},
328+
name: "unknown content type",
329+
input: &entity.UploadAttachmentDetail{ContentType: gptr.Of(entity.ContentType("unknown"))},
330+
expected: &app_eval_set.UploadAttachmentDetail{},
338331
},
339332
{
340-
name: "nil content type",
341-
input: &entity.UploadAttachmentDetail{},
342-
expected: &app_eval_set.UploadAttachmentDetail{
343-
ErrorType: gptr.Of(dataset.ItemErrorType(0)),
344-
},
333+
name: "nil content type",
334+
input: &entity.UploadAttachmentDetail{},
335+
expected: &app_eval_set.UploadAttachmentDetail{},
345336
},
346337
{
347338
name: "full fields",

0 commit comments

Comments
 (0)