(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestEcho(t *testing.T) { |
| 18 | t.Parallel() |
| 19 | |
| 20 | workdir := t.TempDir() |
| 21 | |
| 22 | // Create an in-memory provisioner to communicate with. |
| 23 | client, server := drpcsdk.MemTransportPipe() |
| 24 | ctx, cancelFunc := context.WithCancel(context.Background()) |
| 25 | t.Cleanup(func() { |
| 26 | _ = client.Close() |
| 27 | _ = server.Close() |
| 28 | cancelFunc() |
| 29 | }) |
| 30 | go func() { |
| 31 | err := echo.Serve(ctx, &provisionersdk.ServeOptions{ |
| 32 | Listener: server, |
| 33 | WorkDirectory: workdir, |
| 34 | }) |
| 35 | assert.NoError(t, err) |
| 36 | }() |
| 37 | api := proto.NewDRPCProvisionerClient(client) |
| 38 | |
| 39 | t.Run("Parse", func(t *testing.T) { |
| 40 | t.Parallel() |
| 41 | ctx, cancel := context.WithTimeout(ctx, testutil.WaitShort) |
| 42 | defer cancel() |
| 43 | |
| 44 | responses := []*proto.Response{ |
| 45 | { |
| 46 | Type: &proto.Response_Log{ |
| 47 | Log: &proto.Log{ |
| 48 | Output: "log-output", |
| 49 | }, |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | Type: &proto.Response_Parse{ |
| 54 | Parse: &proto.ParseComplete{}, |
| 55 | }, |
| 56 | }, |
| 57 | } |
| 58 | data, err := echo.Tar(&echo.Responses{ |
| 59 | Parse: responses, |
| 60 | ProvisionInit: echo.InitComplete, |
| 61 | }) |
| 62 | require.NoError(t, err) |
| 63 | client, err := api.Session(ctx) |
| 64 | require.NoError(t, err) |
| 65 | defer func() { |
| 66 | err := client.Close() |
| 67 | require.NoError(t, err) |
| 68 | }() |
| 69 | err = client.Send(&proto.Request{Type: &proto.Request_Config{Config: &proto.Config{}}}) |
| 70 | require.NoError(t, err) |
| 71 | |
| 72 | err = client.Send(&proto.Request{Type: &proto.Request_Init{Init: &proto.InitRequest{ |
| 73 | TemplateSourceArchive: data, |
| 74 | }}}) |
nothing calls this directly
no test coverage detected