Skip to content

Commit

Permalink
Move fn tests off deprecated GRPC APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Jul 26, 2024
1 parent 471b43b commit a586383
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions framework/testing/do.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
2 changes: 1 addition & 1 deletion internal/frontend/scaffold/gengotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testdata/tests/localstacks3/tests3demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testdata/tests/modeling/scopes/testscoping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testdata/tests/postgres/testlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/testdata/tests/prometheus/canscrape/testscrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
Expand Down

0 comments on commit a586383

Please sign in to comment.