github.com/quay/claircore@v1.5.28/test/repository.go (about)

     1  package test
     2  
     3  import (
     4  	"fmt"
     5  	"strconv"
     6  
     7  	"github.com/quay/claircore"
     8  )
     9  
    10  // GenUniqueRepositories creates an array of unique repositories.
    11  //
    12  // The array is guaranteed not to have any duplicated fields.
    13  func GenUniqueRepositories(n int, opts ...GenRepoOption) []*claircore.Repository {
    14  	repos := []*claircore.Repository{}
    15  	for i := 0; i < n; i++ {
    16  		r := claircore.Repository{
    17  			ID:   strconv.Itoa(i),
    18  			Name: fmt.Sprintf("repository-%d", i),
    19  			Key:  fmt.Sprintf("key-%d", i),
    20  			URI:  fmt.Sprintf("uri-%d", i),
    21  		}
    22  		for _, f := range opts {
    23  			f(&r)
    24  		}
    25  		repos = append(repos, &r)
    26  	}
    27  	return repos
    28  }
    29  
    30  // GenRepoOption is a functional option to [GenUniqueRepositories].
    31  type GenRepoOption func(*claircore.Repository)