Skip to content

Commit

Permalink
Add net/grpc test
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Feb 6, 2025
1 parent 7915a2f commit 95e58e9
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion internal/js/modules/k6/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,6 @@ func TestClientLoadProto(t *testing.T) {
ts := newTestState(t)

tt := testcase{
name: "LoadNestedTypesProto",
initString: codeBlock{
code: `
var client = new grpc.Client();
Expand Down Expand Up @@ -1402,6 +1401,40 @@ func TestClientLoadProto(t *testing.T) {
}
}

func TestClientLoadProtoAbsoluteRootWithFile(t *testing.T) {
t.Parallel()

ts := newTestState(t)
pwd := "file://" + ts.VU.InitEnvField.CWD.JoinPath("../..").String()

tt := testcase{
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load(["` + pwd + `"], "../../lib/testutils/httpmultibin/nested_types/nested_types.proto");`,
},
}

val, err := ts.Run(tt.initString.code)
assertResponse(t, tt.initString, err, val, ts)

expectedTypes := []string{
"grpc.testdata.nested.types.Outer",
"grpc.testdata.nested.types.Outer.MiddleAA",
"grpc.testdata.nested.types.Outer.MiddleAA.Inner",
"grpc.testdata.nested.types.Outer.MiddleBB",
"grpc.testdata.nested.types.Outer.MiddleBB.Inner",
"grpc.testdata.nested.types.MeldOuter",
}

for _, expected := range expectedTypes {
found, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(expected))

assert.NotNil(t, found, "Expected to find the message type %s, but an error occurred", expected)
assert.Nil(t, err, "It was not expected that there would be an error, but it got: %v", err)
}
}

func TestClientConnectionReflectMetadata(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 95e58e9

Please sign in to comment.