Skip to content

Commit

Permalink
Fix atricle article typo
Browse files Browse the repository at this point in the history
  • Loading branch information
billmakes committed Sep 1, 2021
1 parent 0ec27ae commit 0a2913e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions controllers/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var articleForm = new(forms.ArticleForm)
func (ctrl ArticleController) Create(c *gin.Context) {
userID := getUserID(c)

var form forms.CreateAtricleForm
var form forms.CreateArticleForm

if validationErr := c.ShouldBindJSON(&form); validationErr != nil {
message := articleForm.Create(validationErr)
Expand Down Expand Up @@ -84,7 +84,7 @@ func (ctrl ArticleController) Update(c *gin.Context) {
return
}

var form forms.CreateAtricleForm
var form forms.CreateArticleForm

if validationErr := c.ShouldBindJSON(&form); validationErr != nil {
message := articleForm.Create(validationErr)
Expand Down
4 changes: 2 additions & 2 deletions forms/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
//ArticleForm ...
type ArticleForm struct{}

//CreateAtricleForm ...
type CreateAtricleForm struct {
//CreateArticleForm ...
type CreateArticleForm struct {
Title string `form:"title" json:"title" binding:"required,min=3,max=100"`
Content string `form:"content" json:"content" binding:"required,min=3,max=1000"`
}
Expand Down
4 changes: 2 additions & 2 deletions models/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Article struct {
type ArticleModel struct{}

//Create ...
func (m ArticleModel) Create(userID int64, form forms.CreateAtricleForm) (articleID int64, err error) {
func (m ArticleModel) Create(userID int64, form forms.CreateArticleForm) (articleID int64, err error) {
err = db.GetDB().QueryRow("INSERT INTO public.article(user_id, title, content) VALUES($1, $2, $3) RETURNING id", userID, form.Title, form.Content).Scan(&articleID)
return articleID, err
}
Expand All @@ -40,7 +40,7 @@ func (m ArticleModel) All(userID int64) (articles []DataList, err error) {
}

//Update ...
func (m ArticleModel) Update(userID int64, id int64, form forms.CreateAtricleForm) (err error) {
func (m ArticleModel) Update(userID int64, id int64, form forms.CreateArticleForm) (err error) {
//METHOD 1
//Check the article by ID using this way
// _, err = m.One(userID, id)
Expand Down
6 changes: 3 additions & 3 deletions tests/article_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func TestInvalidLogin(t *testing.T) {
func TestCreateArticle(t *testing.T) {
testRouter := SetupRouter()

var form forms.CreateAtricleForm
var form forms.CreateArticleForm

form.Title = "Testing article title"
form.Content = "Testing article content"
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestCreateArticle(t *testing.T) {
func TestCreateInvalidArticle(t *testing.T) {
testRouter := SetupRouter()

var form forms.CreateAtricleForm
var form forms.CreateArticleForm

form.Title = "Testing article title"

Expand Down Expand Up @@ -421,7 +421,7 @@ func TestGetArticleUnauthorized(t *testing.T) {
func TestUpdateArticle(t *testing.T) {
testRouter := SetupRouter()

var form forms.CreateAtricleForm
var form forms.CreateArticleForm

form.Title = "Testing new article title"
form.Content = "Testing new article content"
Expand Down

0 comments on commit 0a2913e

Please sign in to comment.