From a58638382eb673da43859ac3e730c453847c3c02 Mon Sep 17 00:00:00 2001 From: Niklas Gehlen Date: Fri, 26 Jul 2024 16:14:12 +0200 Subject: [PATCH] Move fn tests off deprecated GRPC APIs --- framework/testing/do.go | 5 ++--- internal/frontend/scaffold/gengotest.go | 2 +- internal/testdata/tests/localstacks3/tests3demo.go | 2 +- internal/testdata/tests/modeling/scopes/testscoping.go | 2 +- internal/testdata/tests/postgres/testlist.go | 2 +- internal/testdata/tests/prometheus/canscrape/testscrape.go | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/framework/testing/do.go b/framework/testing/do.go index d0d4a8a24..119adaeb0 100644 --- a/framework/testing/do.go +++ b/framework/testing/do.go @@ -27,9 +27,8 @@ type Test struct { testboot.TestData } -func (t Test) Connect(ctx context.Context, endpoint *schema.Endpoint) (*grpc.ClientConn, error) { - return grpc.DialContext(ctx, endpoint.Address(), - grpc.WithBlock(), +func (t Test) NewClient(endpoint *schema.Endpoint) (*grpc.ClientConn, error) { + return grpc.NewClient(endpoint.Address(), grpc.WithTransportCredentials(insecure.NewCredentials())) /// XXX mTLS etc. } diff --git a/internal/frontend/scaffold/gengotest.go b/internal/frontend/scaffold/gengotest.go index 2f338411b..8d9c9dd1e 100644 --- a/internal/frontend/scaffold/gengotest.go +++ b/internal/frontend/scaffold/gengotest.go @@ -52,7 +52,7 @@ import ( func main() { testing.Do(func(ctx context.Context, t testing.Test) error { - conn, err := t.Connect(ctx, t.MustEndpoint("{{.ServicePkg}}", "{{.ServiceImportAlias}}")) + conn, err := t.NewClient(t.MustEndpoint("{{.ServicePkg}}", "{{.ServiceImportAlias}}")) if err != nil { return err } diff --git a/internal/testdata/tests/localstacks3/tests3demo.go b/internal/testdata/tests/localstacks3/tests3demo.go index 47ee514b3..a0e06f68f 100644 --- a/internal/testdata/tests/localstacks3/tests3demo.go +++ b/internal/testdata/tests/localstacks3/tests3demo.go @@ -16,7 +16,7 @@ func main() { testing.Do(func(ctx context.Context, t testing.Test) error { endpoint := t.MustEndpoint("namespacelabs.dev/foundation/internal/testdata/service/localstacks3", "localstacks3") - conn, err := t.Connect(ctx, endpoint) + conn, err := t.NewClient(endpoint) if err != nil { return err } diff --git a/internal/testdata/tests/modeling/scopes/testscoping.go b/internal/testdata/tests/modeling/scopes/testscoping.go index 0ea489a15..0ac55c092 100644 --- a/internal/testdata/tests/modeling/scopes/testscoping.go +++ b/internal/testdata/tests/modeling/scopes/testscoping.go @@ -16,7 +16,7 @@ func main() { testing.Do(func(ctx context.Context, t testing.Test) error { endpoint := t.MustEndpoint("namespacelabs.dev/foundation/internal/testdata/service/count", "count") - conn, err := t.Connect(ctx, endpoint) + conn, err := t.NewClient(endpoint) if err != nil { return err } diff --git a/internal/testdata/tests/postgres/testlist.go b/internal/testdata/tests/postgres/testlist.go index 977e9cdeb..f2762bda2 100644 --- a/internal/testdata/tests/postgres/testlist.go +++ b/internal/testdata/tests/postgres/testlist.go @@ -18,7 +18,7 @@ func main() { testing.Do(func(ctx context.Context, t testing.Test) error { endpoint := t.MustEndpoint("namespacelabs.dev/foundation/internal/testdata/service/list", "list") - conn, err := t.Connect(ctx, endpoint) + conn, err := t.NewClient(endpoint) if err != nil { return err } diff --git a/internal/testdata/tests/prometheus/canscrape/testscrape.go b/internal/testdata/tests/prometheus/canscrape/testscrape.go index 7f1700cd7..2fa0a761f 100644 --- a/internal/testdata/tests/prometheus/canscrape/testscrape.go +++ b/internal/testdata/tests/prometheus/canscrape/testscrape.go @@ -16,9 +16,9 @@ import ( dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "namespacelabs.dev/foundation/framework/testing" + "namespacelabs.dev/foundation/internal/testdata/service/proto" "namespacelabs.dev/foundation/schema" "namespacelabs.dev/foundation/schema/schemahelper" - "namespacelabs.dev/foundation/internal/testdata/service/proto" ) func main() { @@ -36,7 +36,7 @@ func main() { return errors.New("prometheus metrics endpoint missing") } - conn, err := t.Connect(ctx, endpoint) + conn, err := t.NewClient(endpoint) if err != nil { return err }