mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
Complete file tree and packages managment rework
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package articles
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
var Article1, _ = bson.Marshal(Article{
|
||||
IdName: "test_article_1",
|
||||
Date: 1671482492,
|
||||
Content: gin.H{},
|
||||
})
|
||||
|
||||
var Article2, _ = bson.Marshal(Article{
|
||||
IdName: "test_article_2",
|
||||
Date: 1671899112,
|
||||
Content: gin.H{},
|
||||
})
|
||||
|
||||
var BSONConvertedArticles = [][]byte{Article1, Article2}
|
||||
|
||||
func TestGetAllArticlesBusiness(t *testing.T) {
|
||||
documents := GetAllArticlesBusiness(BSONConvertedArticles)
|
||||
article := documents[0]
|
||||
|
||||
if article.IdName != "test_article_1" {
|
||||
log.Fatalf(`Excepted "test_article_1" as IdName, found "%v"`, article.IdName)
|
||||
} else if article.Date != 1671482492 {
|
||||
log.Fatalf(`Excepted 1671482492 as Date, found "%v"`, article.Date)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsArticleIdAlreadyUsed(t *testing.T) {
|
||||
if IsArticleIdAlreadyUsed("test_article_1", BSONConvertedArticles) == false {
|
||||
log.Fatalf(`Excepted true, found false`)
|
||||
} else if IsArticleIdAlreadyUsed("test_article_3", BSONConvertedArticles) == true {
|
||||
log.Fatalf(`Excepted false, found true`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user