SDK v3 #8

Merged
SoXX merged 77 commits from dev/issue-5 into main 2024-08-14 13:27:35 +00:00
Showing only changes of commit b7e3877b68 - Show all commits

View File

@ -3,10 +3,12 @@ package test
import ( import (
"fmt" "fmt"
"math/rand" "math/rand"
"time"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models" "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
gonanoid "github.com/matoous/go-nanoid/v2" gonanoid "github.com/matoous/go-nanoid/v2"
"gorm.io/gorm"
) )
func GenerateRandomTags(numTags int) []models.Tag { func GenerateRandomTags(numTags int) []models.Tag {
@ -67,3 +69,33 @@ func GenerateRandomTagAlias(tags []models.Tag, numGroups int) []models.TagAlias
return tagAliases 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
}