func updateTimeoutInAction(logger lager.Logger, action *models.Action) { if action == nil { logger.Debug("no-action-to-convert") return } a := action.GetValue() switch actionModel := a.(type) { case *models.RunAction, *models.DownloadAction, *models.UploadAction: return case *models.TimeoutAction: timeoutAction := actionModel timeoutAction.TimeoutMs = timeoutAction.DeprecatedTimeoutNs / 1000000 case *models.EmitProgressAction: updateTimeoutInAction(logger, actionModel.Action) case *models.TryAction: updateTimeoutInAction(logger, actionModel.Action) case *models.ParallelAction: for _, subaction := range actionModel.Actions { updateTimeoutInAction(logger, subaction) } case *models.SerialAction: for _, subaction := range actionModel.Actions { updateTimeoutInAction(logger, subaction) } case *models.CodependentAction: for _, subaction := range actionModel.Actions { updateTimeoutInAction(logger, subaction) } } }
Expect(err).NotTo(HaveOccurred()) Expect(json).To(MatchJSON("null")) }) }) It("JSON -> Action for Nil action", func() { By("unwrapping", func() { var unmarshalledAction *models.Action err := json.Unmarshal([]byte("null"), &unmarshalledAction) Expect(err).NotTo(HaveOccurred()) Expect(unmarshalledAction).To(BeNil()) }) }) Describe("Validate", func() { var action *models.Action Context("when the action has no inner actions", func() { It("is valid", func() { action = nil err := action.Validate() Expect(err).NotTo(HaveOccurred()) }) }) }) }) Describe("Download", func() { var downloadAction *models.DownloadAction