fix: don't call Apply() twice

For some reason this was called by `Run()`. All tests pass without it,
so I'm not sure why it was there.

Fixes #481
This commit is contained in:
Alec Thomas
2024-12-29 07:42:25 +09:00
parent 840220c2ed
commit a14bb2072c
2 changed files with 24 additions and 5 deletions
+24
View File
@@ -2439,3 +2439,27 @@ func TestEmbeddedCallbacks(t *testing.T) {
}
assert.Equal(t, expected, actual)
}
type applyCalledOnce struct {
Dev bool
}
func (c *applyCalledOnce) AfterApply() error {
c.Dev = false
return nil
}
func (c applyCalledOnce) Run() error {
if c.Dev {
return fmt.Errorf("--dev should not be set")
}
return nil
}
func TestApplyCalledOnce(t *testing.T) {
cli := &applyCalledOnce{}
kctx, err := mustNew(t, cli).Parse([]string{"--dev"})
assert.NoError(t, err)
err = kctx.Run()
assert.NoError(t, err)
}