Skip to content

Commit

Permalink
Merge pull request #3 from dexfs/feat/improvements
Browse files Browse the repository at this point in the history
feat: improvements
  • Loading branch information
dexfs authored Apr 18, 2024
2 parents ded836b + f8fd232 commit 7dd3479
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestUserInfoResource(t *testing.T) {

var got app.GetUserInfoOutput

if err := json.NewDecoder(response.Body).Decode(&got); err != nil {
if err := helperDecodeJSON(response.Body, &got); err != nil {
fmt.Errorf("could not decode JSON: %v", err)
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestUserFeedResource(t *testing.T) {

var got app.GetUserFeedUseCaseOutput

if err := json.NewDecoder(response.Body).Decode(&got); err != nil {
if err := helperDecodeJSON(response.Body, &got); err != nil {
fmt.Errorf("could not decode JSON: %v", err)
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func TestCreatePostResource(t *testing.T) {

var got app.CreatePostOutput

if err := json.NewDecoder(response.Body).Decode(&got); err != nil {
if err := helperDecodeJSON(response.Body, &got); err != nil {
fmt.Errorf("could not decode JSON: %v", err)
}

Expand Down Expand Up @@ -263,7 +263,7 @@ func TestCreateQuotePostResource(t *testing.T) {

var got app.CreateQuotePostUseCaseOutput

if err := json.NewDecoder(response.Body).Decode(&got); err != nil {
if err := helperDecodeJSON(response.Body, &got); err != nil {
t.Fatalf("could not decode JSON: %v", err)
}

Expand Down Expand Up @@ -291,14 +291,14 @@ func TestCreateQuotePostResource_WithTheOriginalUser_ReturnsError(t *testing.T)
server.ServeHTTP(response, request)

var got struct {
Error string `json:"error"`
Error string
}

if err := helperDecodeJSON(response.Body, &got); err != nil {
t.Fatal(err)
}

want := "it is not possible repost your own post"
want := "it is not possible quote your own post"
if got.Error != want {
t.Errorf("got %s, want %s", got.Error, want)
}
Expand Down Expand Up @@ -331,7 +331,7 @@ func TestCreateRepostResource(t *testing.T) {

var got app.CreateRepostUseCaseOutput

if err := json.NewDecoder(response.Body).Decode(&got); err != nil {
if err := helperDecodeJSON(response.Body, &got); err != nil {
t.Fatalf("could not decode JSON: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/domain/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func NewQuote(aNewQuoteInput NewRepostQuoteInput) (*Post, error) {
}

if aNewQuoteInput.Post.User.ID == aNewQuoteInput.User.ID {
return nil, errors.New("it is not possible repost your own post")
return nil, errors.New("it is not possible quote your own post")
}

return &Post{
Expand Down
4 changes: 2 additions & 2 deletions internal/domain/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func TestNewQuotepost_WithSameUserID_ReturnsError(t *testing.T) {
t.Errorf("Invalid instance of QuotePost returned")
}

if "it is not possible repost your own post" != err.Error() {
t.Errorf("Returned error is not correct. got '%s' want '%s'", err.Error(), "it is not possible repost your own post")
if "it is not possible quote your own post" != err.Error() {
t.Errorf("Returned error is not correct. got '%s' want '%s'", err.Error(), "it is not possible quote your own post")
}
}
func TestNewQuotepost_WithQuotepost_ReturnsError(t *testing.T) {
Expand Down

0 comments on commit 7dd3479

Please sign in to comment.