(t *testing.T)
| 34 | var mockArgs = []string{"shell", "finch"} |
| 35 | |
| 36 | func TestNerdctlCmdCreator_Create(t *testing.T) { |
| 37 | t.Parallel() |
| 38 | |
| 39 | testCases := []struct { |
| 40 | name string |
| 41 | mockSvc func(*mocks.Logger, *mocks.CommandCreator, *mocks.Command, *mocks.NerdctlCmdCreatorSystemDeps) |
| 42 | wantErr error |
| 43 | }{ |
| 44 | { |
| 45 | name: "happy path", |
| 46 | wantErr: nil, |
| 47 | mockSvc: func(logger *mocks.Logger, cmdCreator *mocks.CommandCreator, cmd *mocks.Command, lcd *mocks.NerdctlCmdCreatorSystemDeps) { |
| 48 | logger.EXPECT().Debugf("Creating limactl command: ARGUMENTS: %v, %s: %s", mockArgs, command.EnvKeyLimaHome, mockLimaHomePath) |
| 49 | cmdCreator.EXPECT().Create(mockLimactlPath, mockArgs).Return(cmd) |
| 50 | lcd.EXPECT().Environ().Return([]string{}) |
| 51 | lcd.EXPECT().Stdin().Return(nil) |
| 52 | lcd.EXPECT().Stdout().Return(nil) |
| 53 | lcd.EXPECT().Stderr().Return(nil) |
| 54 | lcd.EXPECT().Env(command.EnvKeyPath).Return(mockSystemPath) |
| 55 | cmd.EXPECT().SetEnv([]string{ |
| 56 | fmt.Sprintf("%s=%s", command.EnvKeyLimaHome, mockLimaHomePath), |
| 57 | fmt.Sprintf("%s=%s", command.EnvKeyPath, finalPath), |
| 58 | }) |
| 59 | cmd.EXPECT().SetStdin(nil) |
| 60 | cmd.EXPECT().SetStdout(nil) |
| 61 | cmd.EXPECT().SetStderr(nil) |
| 62 | }, |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | for _, tc := range testCases { |
| 67 | t.Run(tc.name, func(t *testing.T) { |
| 68 | t.Parallel() |
| 69 | |
| 70 | ctrl := gomock.NewController(t) |
| 71 | cmdCreator := mocks.NewCommandCreator(ctrl) |
| 72 | cmd := mocks.NewCommand(ctrl) |
| 73 | logger := mocks.NewLogger(ctrl) |
| 74 | lcd := mocks.NewNerdctlCmdCreatorSystemDeps(ctrl) |
| 75 | tc.mockSvc(logger, cmdCreator, cmd, lcd) |
| 76 | command.NewNerdctlCmdCreator(cmdCreator, logger, mockLimaHomePath, mockLimactlPath, mockQemuBinPath, lcd).Create(mockArgs...) |
| 77 | }) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func TestNerdctlCmdCreator_CreateWithoutStdio(t *testing.T) { |
| 82 | t.Parallel() |
nothing calls this directly
no test coverage detected