Skip to content

Commit

Permalink
testing: article testing (#110)
Browse files Browse the repository at this point in the history
testing: article testing
  • Loading branch information
masnann authored Dec 17, 2023
2 parents ba54842 + bca5519 commit 40305cc
Show file tree
Hide file tree
Showing 14 changed files with 3,154 additions and 69 deletions.
9 changes: 3 additions & 6 deletions module/entities/carousel_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ type CarouselModels struct {
ID uint64 `gorm:"column:id;type:BIGINT UNSIGNED;primaryKey" json:"id"`
Name string `gorm:"column:name;type:VARCHAR(255)" json:"name"`
Photo string `gorm:"column:photo;type:VARCHAR(255)" json:"photo"`
// CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP" json:"created_at"`
// UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP" json:"updated_at"`
// DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
}

func (CarouselModels) TableName() string {
Expand Down
2 changes: 1 addition & 1 deletion module/entities/challenge_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ChallengeFormModels struct {
ID uint64 `gorm:"column:id;type:BIGINT UNSIGNED;primaryKey" json:"id"`
UserID uint64 `gorm:"column:user_id;type:BIGINT UNSIGNED" json:"user_id"`
ChallengeID uint64 `gorm:"column:challenge_id;type:BIGINT UNSIGNED" json:"challenge_id"`
Username string `gorm:"column:username;type:username" json:"username"`
Username string `gorm:"column:username;type:varchar(255)" json:"username"`
Photo string `gorm:"column:photo;type:varchar(255)" json:"photo"`
Status string `gorm:"column:status;type:varchar(255)" json:"status"`
Exp uint64 `gorm:"column:exp;type:int" json:"exp"`
Expand Down
18 changes: 6 additions & 12 deletions module/entities/reviews_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@ type ReviewModels struct {
Rating uint64 `gorm:"column:rating;type:BIGINT UNSIGNED" json:"rating"`
Description string `gorm:"column:description;type:text" json:"description"`
Date time.Time `gorm:"column:date;type:DATETIME" json:"date"`
// CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP" json:"created_at"`
// UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP" json:"updated_at"`
// DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
Photos []ReviewPhotoModels `gorm:"foreignKey:ReviewID" json:"photos"`
}

type ReviewPhotoModels struct {
ID uint64 `gorm:"column:id;type:BIGINT UNSIGNED;primaryKey" json:"id"`
ReviewID uint64 `gorm:"column:review_id;type:BIGINT UNSIGNED" json:"review_id"`
ImageURL string `gorm:"column:url;type:varchar(255)" json:"url"`
// CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP" json:"created_at"`
// UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP" json:"updated_at"`
// DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
}

type ReviewDetail struct {
Expand Down
9 changes: 3 additions & 6 deletions module/entities/voucher_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ type VoucherModels struct {
MinPurchase uint64 `gorm:"column:min_purchase;type:BIGINT UNSIGNED" json:"min_purchase" `
Stock uint64 `gorm:"column:stock;type:BIGINT UNSIGNED" json:"stock" `
Status string `gorm:"column:status;type:VARCHAR(255)" json:"status" `
// CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP" json:"created_at"`
// UpdatedAt time.Time `gorm:"column:updated_at;type:TIMESTAMP" json:"updated_at"`
// DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp DEFAULT CURRENT_TIMESTAMP" json:"updated_at"`
DeletedAt *time.Time `gorm:"column:deleted_at;type:TIMESTAMP NULL;index" json:"deleted_at"`
}

func (VoucherModels) TableName() string {
Expand Down
41 changes: 21 additions & 20 deletions module/feature/article/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,27 @@ type RepositoryArticleInterface interface {
}

type ServiceArticleInterface interface {
CreateArticle(articleData *entities.ArticleModels) (*entities.ArticleModels, error)
UpdateArticleById(id uint64, updatedArticle *entities.ArticleModels) (*entities.ArticleModels, error)
DeleteArticleById(id uint64) error
GetAll() ([]*entities.ArticleModels, error)
GetArticlesByTitle(title string) ([]*entities.ArticleModels, error)
GetArticleById(id uint64, incrementVIews bool) (*entities.ArticleModels, error)
GetArticlesByDateRange(filterType string) ([]*entities.ArticleModels, error)
BookmarkArticle(bookmark *entities.ArticleBookmarkModels) error
DeleteBookmarkArticle(userID, articleID uint64) error
GetUserBookmarkArticle(userID uint64) ([]*entities.ArticleBookmarkModels, error)
GetLatestArticles() ([]*entities.ArticleModels, error)
GetOldestArticle(page, perPage int) ([]*entities.ArticleModels, int64, error)
GetNextPage(currentPage int, totalPages int) int
GetPrevPage(currentPage int) int
CalculatePaginationValues(page int, totalItems int, perPage int) (int, int)
GetArticlesAlphabet(page, perPage int) ([]*entities.ArticleModels, int64, error)
GetArticleMostViews(page, perPage int) ([]*entities.ArticleModels, int64, error)
GetOtherArticle() ([]*entities.ArticleModels, error)
GetArticleSearchByDateRange(filterType, searchText string) ([]*entities.ArticleModels, error)
GetAllArticleUser(page, perPage int) ([]*entities.ArticleModels, int64, error)
/*?*/CreateArticle(articleData *entities.ArticleModels) (*entities.ArticleModels, error)
/*?*/UpdateArticleById(id uint64, updatedArticle *entities.ArticleModels) (*entities.ArticleModels, error)
/*?*/DeleteArticleById(id uint64) error
/*?*/GetAll() ([]*entities.ArticleModels, error)
/*?*/GetArticlesByTitle(title string) ([]*entities.ArticleModels, error)
/*?*/GetArticleById(id uint64, incrementVIews bool) (*entities.ArticleModels, error)
/*?*/GetArticlesByDateRange(filterType string) ([]*entities.ArticleModels, error)
/*?*/GetLatestArticles() ([]*entities.ArticleModels, error)
/*?*/GetOldestArticle(page, perPage int) ([]*entities.ArticleModels, int64, error)
/*?*/GetArticlesAlphabet(page, perPage int) ([]*entities.ArticleModels, int64, error)
/*?*/GetArticleMostViews(page, perPage int) ([]*entities.ArticleModels, int64, error)
/*?*/GetOtherArticle() ([]*entities.ArticleModels, error)
/*1 case lagi*/GetArticleSearchByDateRange(filterType, searchText string) ([]*entities.ArticleModels, error)
/*?*/GetAllArticleUser(page, perPage int) ([]*entities.ArticleModels, int64, error)
/*?*/BookmarkArticle(bookmark *entities.ArticleBookmarkModels) error
/*?*/DeleteBookmarkArticle(userID, articleID uint64) error
/*?*/GetUserBookmarkArticle(userID uint64) ([]*entities.ArticleBookmarkModels, error)
/*?*/GetNextPage(currentPage int, totalPages int) int
/*?*/GetPrevPage(currentPage int) int
/*?*/CalculatePaginationValues(page int, totalItems int, perPage int) (int, int)
GetFilterDateRange(filterType string) (time.Time, time.Time, error)
}

type HandlerArticleInterface interface {
Expand Down
203 changes: 203 additions & 0 deletions module/feature/article/mocks/HandlerArticleInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 40305cc

Please sign in to comment.