Skip to content

Commit

Permalink
fix(test): SOS posts testcode
Browse files Browse the repository at this point in the history
  • Loading branch information
barabobBOB committed Feb 4, 2024
1 parent 7eaf811 commit 41a0e69
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 124 deletions.
2 changes: 0 additions & 2 deletions internal/domain/sos_post/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func (service *SosPostService) UpdateSosPost(request *UpdateSosPostRequest) (*Up
}
mediaView = append(mediaView, view)
}

conditions, err := service.sosPostStore.FindConditionByID(updateSosPost.ID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -417,7 +416,6 @@ func (service *SosPostService) UpdateSosPost(request *UpdateSosPostRequest) (*Up
}
petsView = append(petsView, p)
}

return &UpdateSosPostView{
ID: updateSosPost.ID,
AuthorID: updateSosPost.AuthorID,
Expand Down
42 changes: 0 additions & 42 deletions internal/domain/sos_post/tests/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ func TestSosPostService(t *testing.T) {
Reward: "Test Reward",
DateStartAt: time.Date(2023, time.December, 18, 8, 00, 0, 0, krLocation),
DateEndAt: time.Date(2023, time.December, 20, 18, 00, 0, 0, krLocation),
TimeStartAt: "10:00",
TimeEndAt: "18:00",
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand Down Expand Up @@ -144,12 +142,6 @@ func TestSosPostService(t *testing.T) {
if sosPost.DateEndAt != "2023-12-20T00:00:00Z" {
t.Errorf("got %v want %v", sosPost.DateEndAt, writeSosPostRequest.DateEndAt)
}
if sosPost.TimeStartAt != "10:00" {
t.Errorf("got %v want %v", sosPost.TimeStartAt, writeSosPostRequest.TimeStartAt)
}
if sosPost.TimeEndAt != "18:00" {
t.Errorf("got %v want %v", sosPost.TimeEndAt, writeSosPostRequest.TimeEndAt)
}
if sosPost.CareType != sos_post.CareTypeFoster {
t.Errorf("got %v want %v", sosPost.CareType, sos_post.CareTypeFoster)
}
Expand Down Expand Up @@ -252,8 +244,6 @@ func TestSosPostService(t *testing.T) {
Reward: fmt.Sprintf("Test Reward%d", i),
DateStartAt: time.Date(2023, time.December, i, 8, 00, 0, 0, krLocation),
DateEndAt: time.Date(2023, time.December, i, 18, 00, 0, 0, krLocation),
TimeStartAt: fmt.Sprintf("10:0%d", i),
TimeEndAt: fmt.Sprintf("18:0%d", i),
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand Down Expand Up @@ -294,12 +284,6 @@ func TestSosPostService(t *testing.T) {
if sosPost.DateEndAt != sosPosts[idx].DateEndAt {
t.Errorf("got %v want %v", sosPost.DateEndAt, sosPosts[idx].DateEndAt)
}
if sosPost.TimeStartAt != sosPosts[idx].TimeStartAt {
t.Errorf("got %v want %v", sosPost.TimeStartAt, sosPosts[idx].TimeStartAt)
}
if sosPost.TimeEndAt != sosPosts[idx].TimeEndAt {
t.Errorf("got %v want %v", sosPost.TimeEndAt, sosPosts[idx].TimeEndAt)
}
if sosPost.CareType != sosPosts[idx].CareType {
t.Errorf("got %v want %v", sosPost.CareType, sosPosts[idx].CareType)
}
Expand Down Expand Up @@ -398,8 +382,6 @@ func TestSosPostService(t *testing.T) {
Reward: fmt.Sprintf("Test Reward%d", i),
DateStartAt: time.Date(2023, time.December, i, 8, 00, 0, 0, krLocation),
DateEndAt: time.Date(2023, time.December, i, 18, 00, 0, 0, krLocation),
TimeStartAt: fmt.Sprintf("10:0%d", i),
TimeEndAt: fmt.Sprintf("18:0%d", i),
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand Down Expand Up @@ -440,12 +422,6 @@ func TestSosPostService(t *testing.T) {
if sosPost.DateEndAt != sosPosts[idx].DateEndAt {
t.Errorf("got %v want %v", sosPost.DateEndAt, sosPosts[idx].DateEndAt)
}
if sosPost.TimeStartAt != sosPosts[idx].TimeStartAt {
t.Errorf("got %v want %v", sosPost.TimeStartAt, sosPosts[idx].TimeStartAt)
}
if sosPost.TimeEndAt != sosPosts[idx].TimeEndAt {
t.Errorf("got %v want %v", sosPost.TimeEndAt, sosPosts[idx].TimeEndAt)
}
if sosPost.CareType != sosPosts[idx].CareType {
t.Errorf("got %v want %v", sosPost.CareType, sosPosts[idx].CareType)
}
Expand Down Expand Up @@ -548,8 +524,6 @@ func TestSosPostService(t *testing.T) {
Reward: fmt.Sprintf("Test Reward%d", i),
DateStartAt: time.Date(2023, time.December, i, 8, 00, 0, 0, krLocation),
DateEndAt: time.Date(2023, time.December, i, 18, 00, 0, 0, krLocation),
TimeStartAt: fmt.Sprintf("10:0%d", i),
TimeEndAt: fmt.Sprintf("18:0%d", i),
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand Down Expand Up @@ -588,12 +562,6 @@ func TestSosPostService(t *testing.T) {
if findSosPostByID.DateEndAt != sosPosts[0].DateEndAt {
t.Errorf("got %v want %v", findSosPostByID.DateEndAt, sosPosts[0].DateEndAt)
}
if findSosPostByID.TimeStartAt != sosPosts[0].TimeStartAt {
t.Errorf("got %v want %v", findSosPostByID.TimeStartAt, sosPosts[0].TimeStartAt)
}
if findSosPostByID.TimeEndAt != sosPosts[0].TimeEndAt {
t.Errorf("got %v want %v", findSosPostByID.TimeEndAt, sosPosts[0].TimeEndAt)
}
if findSosPostByID.CareType != sosPosts[0].CareType {
t.Errorf("got %v want %v", findSosPostByID.CareType, sosPosts[0].CareType)
}
Expand Down Expand Up @@ -693,8 +661,6 @@ func TestSosPostService(t *testing.T) {
Reward: "Test Reward1",
DateStartAt: time.Date(2023, time.December, 0, 8, 00, 0, 0, krLocation),
DateEndAt: time.Date(2023, time.December, 0, 18, 00, 0, 0, krLocation),
TimeStartAt: "10:00",
TimeEndAt: "18:00",
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand All @@ -714,8 +680,6 @@ func TestSosPostService(t *testing.T) {
Reward: "Test Reward2",
DateStartAt: "2023-12-01T00:00:00Z",
DateEndAt: "2023-12-05T00:00:00Z",
TimeStartAt: "10:01",
TimeEndAt: "18:01",
CareType: sos_post.CareTypeFoster,
CarerGender: sos_post.CarerGenderMale,
RewardAmount: sos_post.RewardAmountHour,
Expand Down Expand Up @@ -747,12 +711,6 @@ func TestSosPostService(t *testing.T) {
if updateSosPost.DateEndAt != updateSosPostData.DateEndAt {
t.Errorf("got %v want %v", updateSosPost.DateEndAt, updateSosPostData.DateEndAt)
}
if updateSosPost.TimeStartAt != updateSosPostData.TimeStartAt {
t.Errorf("got %v want %v", updateSosPost.TimeStartAt, updateSosPostData.TimeStartAt)
}
if updateSosPost.TimeEndAt != updateSosPostData.TimeEndAt {
t.Errorf("got %v want %v", updateSosPost.TimeEndAt, updateSosPostData.TimeEndAt)
}
if updateSosPost.CareType != updateSosPostData.CareType {
t.Errorf("got %v want %v", updateSosPost.CareType, updateSosPostData.CareType)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/postgres/sos_post_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (s *SosPostPostgresStore) UpdateSosPost(request *sos_post.UpdateSosPostRequ
thumbnail_id = $9,
updated_at = NOW()
WHERE
id = $12
id = $10
RETURNING id, author_id, title, content, reward, date_start_at, date_end_at, care_type, carer_gender, reward_amount, thumbnail_id`,
request.Title,
request.Content,
Expand All @@ -527,7 +527,7 @@ func (s *SosPostPostgresStore) UpdateSosPost(request *sos_post.UpdateSosPostRequ
&sosPost.ID,
&sosPost.AuthorID,
&sosPost.Title,
sosPost.Content,
&sosPost.Content,
&sosPost.Reward,
&sosPost.DateStartAt,
&sosPost.DateEndAt,
Expand Down
31 changes: 1 addition & 30 deletions pkg/docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT.

// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"
Expand Down Expand Up @@ -1028,12 +1027,6 @@ const docTemplate = `{
"thumbnail_id": {
"type": "integer"
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
},
Expand Down Expand Up @@ -1063,8 +1056,6 @@ const docTemplate = `{
"image_ids",
"reward",
"reward_amount",
"time_end_at",
"time_start_at",
"title"
],
"properties": {
Expand Down Expand Up @@ -1133,12 +1124,6 @@ const docTemplate = `{
}
]
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
}
Expand All @@ -1155,8 +1140,6 @@ const docTemplate = `{
"image_ids",
"reward",
"reward_amount",
"time_end_at",
"time_start_at",
"title"
],
"properties": {
Expand Down Expand Up @@ -1222,12 +1205,6 @@ const docTemplate = `{
}
]
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
}
Expand Down Expand Up @@ -1287,12 +1264,6 @@ const docTemplate = `{
"thumbnail_id": {
"type": "integer"
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
},
Expand Down
28 changes: 0 additions & 28 deletions pkg/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,6 @@
"thumbnail_id": {
"type": "integer"
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
},
Expand Down Expand Up @@ -1055,8 +1049,6 @@
"image_ids",
"reward",
"reward_amount",
"time_end_at",
"time_start_at",
"title"
],
"properties": {
Expand Down Expand Up @@ -1125,12 +1117,6 @@
}
]
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
}
Expand All @@ -1147,8 +1133,6 @@
"image_ids",
"reward",
"reward_amount",
"time_end_at",
"time_start_at",
"title"
],
"properties": {
Expand Down Expand Up @@ -1214,12 +1198,6 @@
}
]
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
}
Expand Down Expand Up @@ -1279,12 +1257,6 @@
"thumbnail_id": {
"type": "integer"
},
"time_end_at": {
"type": "string"
},
"time_start_at": {
"type": "string"
},
"title": {
"type": "string"
},
Expand Down
20 changes: 0 additions & 20 deletions pkg/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ definitions:
$ref: '#/definitions/sos_post.RewardAmount'
thumbnail_id:
type: integer
time_end_at:
type: string
time_start_at:
type: string
title:
type: string
updated_at:
Expand Down Expand Up @@ -317,10 +313,6 @@ definitions:
- $ref: '#/definitions/sos_post.RewardAmount'
enum:
- hour
time_end_at:
type: string
time_start_at:
type: string
title:
type: string
required:
Expand All @@ -333,8 +325,6 @@ definitions:
- image_ids
- reward
- reward_amount
- time_end_at
- time_start_at
- title
type: object
sos_post.WriteSosPostRequest:
Expand Down Expand Up @@ -376,10 +366,6 @@ definitions:
- $ref: '#/definitions/sos_post.RewardAmount'
enum:
- hour
time_end_at:
type: string
time_start_at:
type: string
title:
type: string
required:
Expand All @@ -391,8 +377,6 @@ definitions:
- image_ids
- reward
- reward_amount
- time_end_at
- time_start_at
- title
type: object
sos_post.WriteSosPostView:
Expand Down Expand Up @@ -431,10 +415,6 @@ definitions:
$ref: '#/definitions/sos_post.RewardAmount'
thumbnail_id:
type: integer
time_end_at:
type: string
time_start_at:
type: string
title:
type: string
updated_at:
Expand Down

0 comments on commit 41a0e69

Please sign in to comment.