func TestApp_compileUi(t *testing.T) { client, server := testNewClientServer(t) defer client.Close() appMock := server.AppFunc().(*app.Mock) appReal, err := client.App() if err != nil { t.Fatalf("err: %s", err) } appMock.CompileFunc = func(ctx *app.Context) (*app.CompileResult, error) { ctx.Ui.Message("HELLO!") return nil, nil } ui := new(ui.Mock) ctx := new(app.Context) ctx.Ui = ui _, err = appReal.Compile(ctx) if !appMock.CompileCalled { t.Fatal("compile should be called") } if err != nil { t.Fatalf("bad: %#v", err) } if ui.MessageBuf[0] != "HELLO!" { t.Fatalf("bad: %#v", ui) } }