| 94 | } |
| 95 | |
| 96 | func TestWindowsMinimalApp(t *testing.T) { |
| 97 | // This is not a real test. |
| 98 | // It defines the behavior of the fake application |
| 99 | // that we spawn from TestWindowsCtrlCHandler. |
| 100 | if os.Getenv("FX_TEST_FAKE") != "1" { |
| 101 | return |
| 102 | } |
| 103 | |
| 104 | // An Fx application that prints "ready" to stderr |
| 105 | // once its start hooks have been invoked, |
| 106 | // and "ONSTOP" to stdout when its stop hooks have been invoked. |
| 107 | fx.New( |
| 108 | fx.NopLogger, |
| 109 | fx.Invoke(func(lifecycle fx.Lifecycle) { |
| 110 | lifecycle.Append(fx.Hook{ |
| 111 | OnStart: func(ctx context.Context) error { |
| 112 | fmt.Fprintln(os.Stderr, "ready") |
| 113 | return nil |
| 114 | }, |
| 115 | OnStop: func(ctx context.Context) error { |
| 116 | fmt.Fprintln(os.Stdout, "ONSTOP") |
| 117 | return nil |
| 118 | }, |
| 119 | }) |
| 120 | }), |
| 121 | ).Run() |
| 122 | } |