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 1a41788 commit 79eb1b3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 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

0 comments on commit 79eb1b3

Please sign in to comment.