(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestStepDockerMain(t *testing.T) { |
| 16 | cm := &containerMock{} |
| 17 | |
| 18 | var input *container.NewContainerInput |
| 19 | |
| 20 | // mock the new container call |
| 21 | origContainerNewContainer := ContainerNewContainer |
| 22 | ContainerNewContainer = func(containerInput *container.NewContainerInput) container.ExecutionsEnvironment { |
| 23 | input = containerInput |
| 24 | return cm |
| 25 | } |
| 26 | defer (func() { |
| 27 | ContainerNewContainer = origContainerNewContainer |
| 28 | })() |
| 29 | |
| 30 | ctx := context.Background() |
| 31 | |
| 32 | sd := &stepDocker{ |
| 33 | RunContext: &RunContext{ |
| 34 | StepResults: map[string]*model.StepResult{}, |
| 35 | Config: &Config{}, |
| 36 | Run: &model.Run{ |
| 37 | JobID: "1", |
| 38 | Workflow: &model.Workflow{ |
| 39 | Jobs: map[string]*model.Job{ |
| 40 | "1": { |
| 41 | Defaults: model.Defaults{ |
| 42 | Run: model.RunDefaults{ |
| 43 | Shell: "bash", |
| 44 | }, |
| 45 | }, |
| 46 | }, |
| 47 | }, |
| 48 | }, |
| 49 | }, |
| 50 | JobContainer: cm, |
| 51 | }, |
| 52 | Step: &model.Step{ |
| 53 | ID: "1", |
| 54 | Uses: "docker://node:14", |
| 55 | WorkingDirectory: "workdir", |
| 56 | }, |
| 57 | } |
| 58 | sd.RunContext.ExprEval = sd.RunContext.NewExpressionEvaluator(ctx) |
| 59 | |
| 60 | cm.On("Pull", false).Return(func(_ context.Context) error { |
| 61 | return nil |
| 62 | }) |
| 63 | |
| 64 | cm.On("Remove").Return(func(_ context.Context) error { |
| 65 | return nil |
| 66 | }) |
| 67 | |
| 68 | cm.On("Create", []string(nil), []string(nil)).Return(func(_ context.Context) error { |
| 69 | return nil |
| 70 | }) |
| 71 | |
| 72 | cm.On("Start", true).Return(func(_ context.Context) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…