(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestStub(t *testing.T) { |
| 31 | type want struct { |
| 32 | exit bool |
| 33 | code int |
| 34 | } |
| 35 | tests := []struct { |
| 36 | f func() |
| 37 | want want |
| 38 | }{ |
| 39 | {func() { exit.With(42) }, want{exit: true, code: 42}}, |
| 40 | {func() {}, want{}}, |
| 41 | } |
| 42 | |
| 43 | for _, tt := range tests { |
| 44 | s := exit.WithStub(tt.f) |
| 45 | assert.Equal(t, tt.want.exit, s.Exited, "Stub captured unexpected exit value.") |
| 46 | assert.Equal(t, tt.want.code, s.Code, "Stub captured unexpected exit value.") |
| 47 | } |
| 48 | } |