From 5db1a7e8dd2c3d0fc3e0e6ffd1b217a5e6ba9000 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Fri, 15 Mar 2024 14:35:05 +0000 Subject: [PATCH] Add some unit tests Signed-off-by: Gabriel Adrian Samfira --- params/requests.go | 6 +++--- runner/enterprises.go | 4 ---- runner/organizations.go | 4 ---- runner/pool/util.go | 2 +- runner/repositories.go | 4 ---- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/params/requests.go b/params/requests.go index 81108493..885ed678 100644 --- a/params/requests.go +++ b/params/requests.go @@ -55,7 +55,7 @@ func (c *CreateRepoParams) Validate() error { } switch c.PoolBalancerType { - case PoolBalancerTypeRoundRobin, PoolBalancerTypePack: + case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone: default: return errors.NewBadRequestError("invalid pool balancer type") } @@ -83,7 +83,7 @@ func (c *CreateOrgParams) Validate() error { } switch c.PoolBalancerType { - case PoolBalancerTypeRoundRobin, PoolBalancerTypePack: + case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone: default: return errors.NewBadRequestError("invalid pool balancer type") } @@ -109,7 +109,7 @@ func (c *CreateEnterpriseParams) Validate() error { } switch c.PoolBalancerType { - case PoolBalancerTypeRoundRobin, PoolBalancerTypePack: + case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone: default: return errors.NewBadRequestError("invalid pool balancer type") } diff --git a/runner/enterprises.go b/runner/enterprises.go index 01c5a8d0..c76d3973 100644 --- a/runner/enterprises.go +++ b/runner/enterprises.go @@ -20,10 +20,6 @@ func (r *Runner) CreateEnterprise(ctx context.Context, param params.CreateEnterp return enterprise, runnerErrors.ErrUnauthorized } - if param.PoolBalancerType == "" { - param.PoolBalancerType = params.PoolBalancerTypeRoundRobin - } - err = param.Validate() if err != nil { return params.Enterprise{}, errors.Wrap(err, "validating params") diff --git a/runner/organizations.go b/runner/organizations.go index 2d837fd0..3d24dcda 100644 --- a/runner/organizations.go +++ b/runner/organizations.go @@ -34,10 +34,6 @@ func (r *Runner) CreateOrganization(ctx context.Context, param params.CreateOrgP return org, runnerErrors.ErrUnauthorized } - if param.PoolBalancerType == "" { - param.PoolBalancerType = params.PoolBalancerTypeRoundRobin - } - if err := param.Validate(); err != nil { return params.Organization{}, errors.Wrap(err, "validating params") } diff --git a/runner/pool/util.go b/runner/pool/util.go index 8769fe0b..5a3a3c8c 100644 --- a/runner/pool/util.go +++ b/runner/pool/util.go @@ -61,7 +61,7 @@ func (p *poolsForTags) Get(tags []string) (poolCacheStore, bool) { return poolCache, true } -func (p *poolsForTags) Add(tags []string, pools []params.Pool) *poolRoundRobin { +func (p *poolsForTags) Add(tags []string, pools []params.Pool) poolCacheStore { sort.Slice(pools, func(i, j int) bool { return pools[i].Priority > pools[j].Priority }) diff --git a/runner/repositories.go b/runner/repositories.go index d5b4db77..c71fab39 100644 --- a/runner/repositories.go +++ b/runner/repositories.go @@ -34,10 +34,6 @@ func (r *Runner) CreateRepository(ctx context.Context, param params.CreateRepoPa return repo, runnerErrors.ErrUnauthorized } - if param.PoolBalancerType == "" { - param.PoolBalancerType = params.PoolBalancerTypeRoundRobin - } - if err := param.Validate(); err != nil { return params.Repository{}, errors.Wrap(err, "validating params") }