-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent a panic if the machine is missing (#4060)
Not really sure the condition to trigger the panic, but returning an error would make investigating the issue slightly easier.
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
internal/command/deploy/machines_deploymachinesapp_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package deploy | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/superfly/fly-go" | ||
"github.com/superfly/flyctl/internal/machine" | ||
"github.com/superfly/flyctl/iostreams" | ||
) | ||
|
||
func TestUpdateExistingMachinesWRecovery(t *testing.T) { | ||
ios, _, _, _ := iostreams.Test() | ||
client := &mockFlapsClient{} | ||
client.machines = []*fly.Machine{{ID: "test-machine-id"}} | ||
md := &machineDeployment{ | ||
app: &fly.AppCompact{}, | ||
io: ios, | ||
colorize: ios.ColorScheme(), | ||
flapsClient: client, | ||
strategy: "canary", | ||
} | ||
|
||
ctx := context.Background() | ||
err := md.updateExistingMachinesWRecovery(ctx, nil) | ||
assert.NoError(t, err) | ||
|
||
err = md.updateExistingMachinesWRecovery(ctx, []*machineUpdateEntry{ | ||
{ | ||
leasableMachine: machine.NewLeasableMachine(client, ios, &fly.Machine{}, false), | ||
launchInput: &fly.LaunchMachineInput{}, | ||
}, | ||
}) | ||
assert.Error(t, err, "failed to find machine test-machine-id") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters