feat(test): Add GenerateRandomSources function for creating random sources
This commit is contained in:
parent
2bbfc79e43
commit
b7e3877b68
@ -3,10 +3,12 @@ package test
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
gonanoid "github.com/matoous/go-nanoid/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GenerateRandomTags(numTags int) []models.Tag {
|
||||
@ -67,3 +69,33 @@ func GenerateRandomTagAlias(tags []models.Tag, numGroups int) []models.TagAlias
|
||||
|
||||
return tagAliases
|
||||
}
|
||||
|
||||
func GenerateRandomSources(numTags int) []models.Source {
|
||||
var sources []models.Source
|
||||
|
||||
for i := 0; i < numTags; i++ {
|
||||
id, _ := gonanoid.New(10)
|
||||
displayName, _ := gonanoid.New(10)
|
||||
domain, _ := gonanoid.New(10)
|
||||
icon, _ := gonanoid.New(10)
|
||||
id = spew.Sprintf("source_name_%s", id)
|
||||
|
||||
source := models.Source{
|
||||
BaseModel: models.BaseModel[models.SourceID]{
|
||||
ID: models.SourceID(id),
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
DeletedAt: gorm.DeletedAt{},
|
||||
},
|
||||
DisplayName: displayName,
|
||||
Domain: models.SourceDomain(domain),
|
||||
Icon: icon,
|
||||
UserSources: nil,
|
||||
References: nil,
|
||||
}
|
||||
|
||||
sources = append(sources, source)
|
||||
}
|
||||
|
||||
return sources
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user