abcxyz / jvs

Apache License 2.0
8 stars 0 forks source link

chore: use testutil #82

Closed raserva closed 2 years ago

raserva commented 2 years ago

we manually create servers all over for testing like so:

lis, err := net.Listen("tcp", "localhost:0")
    if err != nil {
        t.Fatal(err)
    }
    // not checked, but makes linter happy
    errs := make(chan error, 1)
    go func() {
        errs <- serv.Serve(lis)
        close(errs)
    }()

    conn, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
    if err != nil {
        t.Fatal(err)
    }
    clientOpt = option.WithGRPCConn(conn)
    t.Cleanup(func() {
        conn.Close()
    })

Instead we should use testutil. https://github.com/abcxyz/pkg/blob/main/testutil/grpc.go

capri-xiyue commented 2 years ago

Verified that testutil https://github.com/abcxyz/pkg/blob/main/testutil/grpc.go has been used across JVS code repo