diff --git a/go.sum b/go.sum index b8e18457a..0bda4f060 100644 --- a/go.sum +++ b/go.sum @@ -108,6 +108,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= @@ -474,6 +475,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= @@ -542,6 +545,9 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -557,6 +563,8 @@ github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vb github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/wundergraph/graphql-go-tools v1.66.4 h1:yRvXYi0jjTghi5zimTluqHXAmyS7JVlGzTlxY6aL0sI= github.com/wundergraph/graphql-go-tools v1.66.4/go.mod h1:obaEJWub7088qodhKbSGHyhRVnHlBP5M9HigN/oalLE= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/internal/graphapi/auth_test.go b/internal/graphapi/auth_test.go index cae7e2125..965990afc 100644 --- a/internal/graphapi/auth_test.go +++ b/internal/graphapi/auth_test.go @@ -12,6 +12,8 @@ import ( "go.infratographer.com/permissions-api/pkg/permissions/mockpermissions" "go.infratographer.com/x/echojwtx" "go.infratographer.com/x/testing/auth" + + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestJWTEnabledLoadbalancerGETWithAuthClient(t *testing.T) { @@ -44,7 +46,7 @@ func TestJWTEnabledLoadbalancerGETWithAuthClient(t *testing.T) { defer srv.Close() - lb1 := (&LoadBalancerBuilder{}).MustNew(ctx) + lb1 := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) resp, err := graphTestClient( withGraphClientHTTPClient(oauthCLI), @@ -85,7 +87,7 @@ func TestJWTENabledLoadbalancerGETWithDefaultClient(t *testing.T) { defer srv.Close() - lb1 := (&LoadBalancerBuilder{}).MustNew(ctx) + lb1 := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) resp, err := graphTestClient( withGraphClientHTTPClient(http.DefaultClient), diff --git a/internal/graphapi/loadbalancer_test.go b/internal/graphapi/loadbalancer_test.go index e9647a726..abd91dbcb 100644 --- a/internal/graphapi/loadbalancer_test.go +++ b/internal/graphapi/loadbalancer_test.go @@ -14,6 +14,7 @@ import ( ent "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestQuery_loadBalancer(t *testing.T) { @@ -26,8 +27,8 @@ func TestQuery_loadBalancer(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb1 := (&LoadBalancerBuilder{}).MustNew(ctx) - lb2 := (&LoadBalancerBuilder{}).MustNew(ctx) + lb1 := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + lb2 := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) testCases := []struct { TestName string @@ -90,7 +91,7 @@ func TestCreate_loadBalancer(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - prov := (&ProviderBuilder{}).MustNew(ctx) + prov := (&testutils.ProviderBuilder{}).MustNew(ctx) ownerID := gidx.MustNewID(ownerPrefix) locationID := gidx.MustNewID(locationPrefix) name := gofakeit.DomainName() @@ -167,7 +168,7 @@ func TestUpdate_loadBalancer(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) updateName := gofakeit.DomainName() testCases := []struct { @@ -242,7 +243,7 @@ func TestDelete_loadBalancer(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) testCases := []struct { TestName string @@ -305,7 +306,7 @@ func TestFullLoadBalancerLifecycle(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - prov := (&ProviderBuilder{}).MustNew(ctx) + prov := (&testutils.ProviderBuilder{}).MustNew(ctx) ownerID := gidx.MustNewID(ownerPrefix) locationID := gidx.MustNewID(locationPrefix) name := gofakeit.DomainName() diff --git a/internal/graphapi/models_test.go b/internal/graphapi/models_test.go deleted file mode 100644 index d243cc18b..000000000 --- a/internal/graphapi/models_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package graphapi_test - -import ( - "context" - - "github.com/brianvoe/gofakeit/v6" - "go.infratographer.com/x/gidx" - - ent "go.infratographer.com/load-balancer-api/internal/ent/generated" - "go.infratographer.com/load-balancer-api/internal/ent/generated/pool" -) - -type ProviderBuilder struct { - Name string - OwnerID gidx.PrefixedID -} - -func (p ProviderBuilder) MustNew(ctx context.Context) *ent.Provider { - if p.Name == "" { - p.Name = gofakeit.JobTitle() - } - - if p.OwnerID == "" { - p.OwnerID = gidx.MustNewID(ownerPrefix) - } - - return EntClient.Provider.Create().SetName(p.Name).SetOwnerID(p.OwnerID).SaveX(ctx) -} - -type LoadBalancerBuilder struct { - Name string - OwnerID gidx.PrefixedID - LocationID gidx.PrefixedID - Provider *ent.Provider -} - -func (b LoadBalancerBuilder) MustNew(ctx context.Context) *ent.LoadBalancer { - if b.Provider == nil { - pb := &ProviderBuilder{OwnerID: b.OwnerID} - b.Provider = pb.MustNew(ctx) - } - - if b.Name == "" { - b.Name = gofakeit.AppName() - } - - if b.OwnerID == "" { - b.OwnerID = b.Provider.OwnerID - } - - if b.LocationID == "" { - b.LocationID = gidx.MustNewID(locationPrefix) - } - - return EntClient.LoadBalancer.Create().SetName(b.Name).SetOwnerID(b.OwnerID).SetLocationID(b.LocationID).SetProvider(b.Provider).SaveX(ctx) -} - -type PortBuilder struct { - Name string - LoadBalancerID gidx.PrefixedID - Number int -} - -func (p PortBuilder) MustNew(ctx context.Context) *ent.Port { - if p.Name == "" { - p.Name = gofakeit.AppName() - } - - if p.LoadBalancerID == "" { - p.LoadBalancerID = gidx.MustNewID(lbPrefix) - } - - if p.Number == 0 { - p.Number = gofakeit.Number(1, 65535) - } - - return EntClient.Port.Create().SetName(p.Name).SetLoadBalancerID(p.LoadBalancerID).SetNumber(p.Number).SaveX(ctx) -} - -type PoolBuilder struct { - Name string - OwnerID gidx.PrefixedID - Protocol pool.Protocol -} - -func (p *PoolBuilder) MustNew(ctx context.Context) *ent.Pool { - if p.Name == "" { - p.Name = gofakeit.AppName() - } - - if p.OwnerID == "" { - p.OwnerID = gidx.MustNewID(ownerPrefix) - } - - if p.Protocol == "" { - p.Protocol = pool.Protocol(gofakeit.RandomString([]string{"tcp", "udp"})) - } - - return EntClient.Pool.Create().SetName(p.Name).SetOwnerID(p.OwnerID).SetProtocol(p.Protocol).SaveX(ctx) -} - -type OriginBuilder struct { - Name string - Target string - PortNumber int - Active bool - PoolID gidx.PrefixedID -} - -func (o *OriginBuilder) MustNew(ctx context.Context) *ent.Origin { - if o.Name == "" { - o.Name = gofakeit.AppName() - } - - if o.Target == "" { - o.Target = gofakeit.IPv4Address() - } - - if o.PortNumber == 0 { - o.PortNumber = gofakeit.Number(1, 65535) - } - - if o.PoolID == "" { - pb := &PoolBuilder{} - o.PoolID = pb.MustNew(ctx).ID - } - - return EntClient.Origin.Create().SetName(o.Name).SetTarget(o.Target).SetPortNumber(o.PortNumber).SetActive(o.Active).SetPoolID(o.PoolID).SaveX(ctx) -} diff --git a/internal/graphapi/origin_test.go b/internal/graphapi/origin_test.go index d2795467d..7f854d44f 100644 --- a/internal/graphapi/origin_test.go +++ b/internal/graphapi/origin_test.go @@ -14,6 +14,7 @@ import ( ent "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestQueryPoolOrigin(t *testing.T) { @@ -26,9 +27,9 @@ func TestQueryPoolOrigin(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{}).MustNew(ctx) - origin1 := (&OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) - origin2 := (&OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{}).MustNew(ctx) + origin1 := (&testutils.OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) + origin2 := (&testutils.OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) testCases := []struct { TestName string @@ -90,7 +91,7 @@ func TestMutate_OriginCreate(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{}).MustNew(ctx) testCases := []struct { TestName string @@ -241,8 +242,8 @@ func TestMutate_OriginUpdate(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{}).MustNew(ctx) - origin1 := (&OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{}).MustNew(ctx) + origin1 := (&testutils.OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) testCases := []struct { TestName string @@ -332,8 +333,8 @@ func TestMutate_OriginDelete(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{}).MustNew(ctx) - origin1 := (&OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{}).MustNew(ctx) + origin1 := (&testutils.OriginBuilder{PoolID: pool1.ID}).MustNew(ctx) testCases := []struct { TestName string diff --git a/internal/graphapi/owner_resolvers_test.go b/internal/graphapi/owner_resolvers_test.go index fa37219b9..e5e3bc97d 100644 --- a/internal/graphapi/owner_resolvers_test.go +++ b/internal/graphapi/owner_resolvers_test.go @@ -13,6 +13,7 @@ import ( ent "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestOwnerLoadBalancersResolver(t *testing.T) { @@ -26,10 +27,10 @@ func TestOwnerLoadBalancersResolver(t *testing.T) { ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) ownerID := gidx.MustNewID("testtnt") - lb1 := (&LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-CCCafdsaf", Name: "lb-a"}).MustNew(ctx) - lb2 := (&LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-AAAfasdf", Name: "lb-c"}).MustNew(ctx) - lb3 := (&LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-BBBasdfa", Name: "lb-1"}).MustNew(ctx) - (&LoadBalancerBuilder{}).MustNew(ctx) + lb1 := (&testutils.LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-CCCafdsaf", Name: "lb-a"}).MustNew(ctx) + lb2 := (&testutils.LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-AAAfasdf", Name: "lb-c"}).MustNew(ctx) + lb3 := (&testutils.LoadBalancerBuilder{OwnerID: ownerID, LocationID: "testloc-BBBasdfa", Name: "lb-1"}).MustNew(ctx) + (&testutils.LoadBalancerBuilder{}).MustNew(ctx) // Update LB1 so it's updated at is most recent lb1.Update().SaveX(ctx) diff --git a/internal/graphapi/pool_test.go b/internal/graphapi/pool_test.go index 3d0f76db7..a359e0606 100644 --- a/internal/graphapi/pool_test.go +++ b/internal/graphapi/pool_test.go @@ -14,6 +14,7 @@ import ( ent "go.infratographer.com/load-balancer-api/internal/ent/generated" pool "go.infratographer.com/load-balancer-api/internal/ent/generated/pool" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestQueryPool(t *testing.T) { @@ -26,8 +27,8 @@ func TestQueryPool(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{}).MustNew(ctx) - pool2 := (&PoolBuilder{}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{}).MustNew(ctx) + pool2 := (&testutils.PoolBuilder{}).MustNew(ctx) testCases := []struct { TestName string @@ -89,8 +90,8 @@ func TestMutate_PoolCreate(t *testing.T) { ownerID := gidx.MustNewID(ownerPrefix) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) - port := (&PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + port := (&testutils.PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) testCases := []struct { TestName string @@ -186,9 +187,9 @@ func TestMutate_PoolUpdate(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{Protocol: "tcp"}).MustNew(ctx) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) - port := (&PortBuilder{LoadBalancerID: lb.ID}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{Protocol: "tcp"}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + port := (&testutils.PortBuilder{LoadBalancerID: lb.ID}).MustNew(ctx) updateProtocolUDP := graphclient.LoadBalancerPoolProtocolUDP testCases := []struct { @@ -290,9 +291,9 @@ func TestMutate_PoolDelete(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - pool1 := (&PoolBuilder{Protocol: "tcp"}).MustNew(ctx) - pool2 := (&PoolBuilder{Protocol: "tcp"}).MustNew(ctx) - _ = (&OriginBuilder{PoolID: pool2.ID}).MustNew(ctx) + pool1 := (&testutils.PoolBuilder{Protocol: "tcp"}).MustNew(ctx) + pool2 := (&testutils.PoolBuilder{Protocol: "tcp"}).MustNew(ctx) + _ = (&testutils.OriginBuilder{PoolID: pool2.ID}).MustNew(ctx) testCases := []struct { TestName string diff --git a/internal/graphapi/port_test.go b/internal/graphapi/port_test.go index 7676f5128..24e6b4ee3 100644 --- a/internal/graphapi/port_test.go +++ b/internal/graphapi/port_test.go @@ -15,6 +15,7 @@ import ( "go.infratographer.com/load-balancer-api/internal/config" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestCreate_LoadbalancerPort(t *testing.T) { @@ -29,9 +30,9 @@ func TestCreate_LoadbalancerPort(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) - poolBad := (&PoolBuilder{}).MustNew(ctx) - _ = (&PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + poolBad := (&testutils.PoolBuilder{}).MustNew(ctx) + _ = (&testutils.PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) testCases := []struct { TestName string @@ -168,10 +169,10 @@ func TestUpdate_LoadbalancerPort(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) - port := (&PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) - poolBad := (&PoolBuilder{}).MustNew(ctx) - _ = (&PortBuilder{Name: "dupeport8080", LoadBalancerID: lb.ID, Number: 8080}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + port := (&testutils.PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) + poolBad := (&testutils.PoolBuilder{}).MustNew(ctx) + _ = (&testutils.PortBuilder{Name: "dupeport8080", LoadBalancerID: lb.ID, Number: 8080}).MustNew(ctx) testCases := []struct { TestName string @@ -300,8 +301,8 @@ func TestDelete_LoadbalancerPort(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) - port := (&PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) + port := (&testutils.PortBuilder{Name: "port80", LoadBalancerID: lb.ID, Number: 80}).MustNew(ctx) testCases := []struct { TestName string @@ -365,7 +366,7 @@ func TestFullLoadBalancerPortLifecycle(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - lb := (&LoadBalancerBuilder{}).MustNew(ctx) + lb := (&testutils.LoadBalancerBuilder{}).MustNew(ctx) name := gofakeit.DomainName() createdPortResp, err := graphTestClient().LoadBalancerPortCreate(ctx, graphclient.CreateLoadBalancerPortInput{ diff --git a/internal/graphapi/provider_test.go b/internal/graphapi/provider_test.go index 3bd1574e7..1d88f4b9d 100644 --- a/internal/graphapi/provider_test.go +++ b/internal/graphapi/provider_test.go @@ -12,6 +12,7 @@ import ( ent "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/graphclient" + "go.infratographer.com/load-balancer-api/internal/testutils" ) func TestQuery_loadBalancerProvider(t *testing.T) { @@ -20,8 +21,8 @@ func TestQuery_loadBalancerProvider(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - p1 := ProviderBuilder{}.MustNew(ctx) - p2 := ProviderBuilder{}.MustNew(ctx) + p1 := (&testutils.ProviderBuilder{}).MustNew(ctx) + p2 := (&testutils.ProviderBuilder{}).MustNew(ctx) testCases := []struct { TestName string @@ -147,7 +148,7 @@ func TestUpdate_Provider(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - prov := ProviderBuilder{}.MustNew(ctx) + prov := (&testutils.ProviderBuilder{}).MustNew(ctx) updateName := gofakeit.DomainName() testCases := []struct { @@ -216,7 +217,7 @@ func TestDelete_Provider(t *testing.T) { // Permit request ctx = context.WithValue(ctx, permissions.CheckerCtxKey, permissions.DefaultAllowChecker) - prov := ProviderBuilder{}.MustNew(ctx) + prov := (&testutils.ProviderBuilder{}).MustNew(ctx) testCases := []struct { TestName string