123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package view
- import (
- "fmt"
- "testing"
- "github.com/gin-gonic/gin"
- "github.com/metarare/metarare_api/common"
- "github.com/metarare/metarare_api/helpers"
- "github.com/spf13/viper"
- "gorm.io/gorm"
- )
- func Test_UserInfo(t *testing.T) {
- _db := initDB()
- userID := uint64(10000)
- err, _user := SelectUserInfo(_db, userID, userID)
- if err != nil {
- t.Error("NO Selected column")
- }
- fmt.Printf("%+v", _user)
- }
- func Test_OwnedTokens(t *testing.T) {
- _db := initDB()
- userID := uint64(10010)
- var _filter common.Filter
- err, selectedToken := SelectOwnedTokens(_db, userID, _filter)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedToken)
- }
- func Test_onSaleItems(t *testing.T) {
- _db := initDB()
- userID := uint64(10010)
- var _filter common.Filter
- err, selectedToken := SelectOnsaleItems(_db, userID, _filter)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedToken)
- }
- func Test_RelatedCollection(t *testing.T) {
- _db := initDB()
- userID := uint64(10008)
- var _filter common.Filter
- _filter.Offset = 0
- _filter.Limit = 3
- err, selectedCollection := SelectRelatedCollection(_db, userID, _filter)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedCollection)
- }
- func Test_LikeTokens(t *testing.T) {
- _db := initDB()
- userID := uint64(10010)
- _filter := common.Filter{
- Offset: 0,
- Limit: 6,
- }
- err, selectedItems := SelectLikedTokens(_db, userID, _filter)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedItems)
- }
- func Test_UserBidHistory(t *testing.T) {
- _db := initDB()
- userID := uint64(10009)
- _filter := common.Filter{
- Offset: 0,
- Limit: 6,
- }
- err, selectedItems := SelectUserBidHistory(_db, userID, _filter)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedItems)
- }
- func Test_UserActivity(t *testing.T) {
- _db := initDB()
- userID := uint64(10002)
- err, selectedItems := SelectUserActivities(_db, userID)
- if err != nil {
- t.Error("NO Selected column")
- }
- t.Logf("tokens : %+v", selectedItems)
- }
- func initDB() *gorm.DB {
- v := helpers.LoadEnvs()
- stage := viper.GetString("stage")
- if stage == "prod" {
- gin.SetMode(gin.ReleaseMode)
- } else {
- gin.SetMode(gin.DebugMode)
- }
- helpers.InitMysqlCommon(v)
- return helpers.MasterDB
- }
|