(t *testing.T)
| 27 | } |
| 28 | |
| 29 | func TestStartVMAction_runAdapter(t *testing.T) { |
| 30 | t.Parallel() |
| 31 | |
| 32 | testCases := []struct { |
| 33 | name string |
| 34 | wantErr error |
| 35 | command *cobra.Command |
| 36 | args []string |
| 37 | groups func(*gomock.Controller) []*dependency.Group |
| 38 | mockSvc func( |
| 39 | *mocks.NerdctlCmdCreator, |
| 40 | *mocks.Logger, |
| 41 | *mocks.LimaConfigApplier, |
| 42 | *mocks.UserDataDiskManager, |
| 43 | *gomock.Controller, |
| 44 | ) |
| 45 | }{ |
| 46 | { |
| 47 | name: "should start instance", |
| 48 | wantErr: nil, |
| 49 | command: &cobra.Command{ |
| 50 | Use: "start", |
| 51 | }, |
| 52 | groups: func(ctrl *gomock.Controller) []*dependency.Group { |
| 53 | dep := mocks.NewDependency(ctrl) |
| 54 | deps := dependency.NewGroup([]dependency.Dependency{dep}, "", "") |
| 55 | groups := []*dependency.Group{deps} |
| 56 | |
| 57 | dep.EXPECT().Installed().Return(false) |
| 58 | dep.EXPECT().RequiresRoot().Return(false) |
| 59 | dep.EXPECT().Install().Return(nil) |
| 60 | |
| 61 | return groups |
| 62 | }, |
| 63 | args: []string{}, |
| 64 | mockSvc: func( |
| 65 | ncc *mocks.NerdctlCmdCreator, |
| 66 | logger *mocks.Logger, |
| 67 | lca *mocks.LimaConfigApplier, |
| 68 | dm *mocks.UserDataDiskManager, |
| 69 | ctrl *gomock.Controller, |
| 70 | ) { |
| 71 | getVMStatusC := mocks.NewCommand(ctrl) |
| 72 | ncc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC) |
| 73 | getVMStatusC.EXPECT().Output().Return([]byte("Stopped"), nil) |
| 74 | logger.EXPECT().Debugf("Status of virtual machine: %s", "Stopped") |
| 75 | |
| 76 | lca.EXPECT().ConfigureOverrideLimaYaml().Return(nil) |
| 77 | |
| 78 | dm.EXPECT().EnsureUserDataDisk().Return(nil) |
| 79 | |
| 80 | command := mocks.NewCommand(ctrl) |
| 81 | command.EXPECT().CombinedOutput() |
| 82 | ncc.EXPECT().CreateWithoutStdio("start", limaInstanceName).Return(command) |
| 83 | |
| 84 | logger.EXPECT().Info("Starting existing Finch virtual machine...") |
| 85 | logger.EXPECT().Info("Finch virtual machine started successfully") |
| 86 | }, |
nothing calls this directly
no test coverage detected