From 9a764fe41a3acc2ebdcaf0567daa8232f69da917 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Tue, 14 May 2024 04:12:08 +0500 Subject: [PATCH] fixed unit test errors --- handlers/features.go | 16 +++++----- mocks/Database.go | 72 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/handlers/features.go b/handlers/features.go index a106f514b..5f4d8119f 100644 --- a/handlers/features.go +++ b/handlers/features.go @@ -125,18 +125,18 @@ func (oh *featureHandler) CreateOrEditFeaturePhase(w http.ResponseWriter, r *htt } func (oh *featureHandler) GetFeaturePhases(w http.ResponseWriter, r *http.Request) { - uuid := chi.URLParam(r, "feature_uuid") - phases := oh.db.GetPhasesByFeatureUuid(uuid) + featureUuid := chi.URLParam(r, "feature_uuid") + phases := oh.db.GetPhasesByFeatureUuid(featureUuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(phases) } func (oh *featureHandler) GetFeaturePhaseByUUID(w http.ResponseWriter, r *http.Request) { - featureUUID := chi.URLParam(r, "feature_uuid") - phaseUUID := chi.URLParam(r, "phase_uuid") + featureUuid := chi.URLParam(r, "feature_uuid") + phaseUuid := chi.URLParam(r, "phase_uuid") - phase, err := oh.db.GetFeaturePhaseByUuid(featureUUID, phaseUUID) + phase, err := oh.db.GetFeaturePhaseByUuid(featureUuid, phaseUuid) if err != nil { w.WriteHeader(http.StatusNotFound) return @@ -147,10 +147,10 @@ func (oh *featureHandler) GetFeaturePhaseByUUID(w http.ResponseWriter, r *http.R } func (oh *featureHandler) DeleteFeaturePhase(w http.ResponseWriter, r *http.Request) { - featureUUID := chi.URLParam(r, "feature_uuid") - phaseUUID := chi.URLParam(r, "phase_uuid") + featureUuid := chi.URLParam(r, "feature_uuid") + phaseUuid := chi.URLParam(r, "phase_uuid") - err := oh.db.DeleteFeaturePhase(featureUUID, phaseUUID) + err := oh.db.DeleteFeaturePhase(featureUuid, phaseUuid) if err != nil { w.WriteHeader(http.StatusNotFound) json.NewEncoder(w).Encode(map[string]string{"error": err.Error()}) diff --git a/mocks/Database.go b/mocks/Database.go index f3a3587d7..f1a49d6a2 100644 --- a/mocks/Database.go +++ b/mocks/Database.go @@ -6660,3 +6660,75 @@ func NewDatabase(t interface { return mock } + +// CreateOrEditFeaturePhase provides a mock function with given fields: phase +func (_m *Database) CreateOrEditFeaturePhase(phase db.FeaturePhase) (db.FeaturePhase, error) { + ret := _m.Called(phase) + + var r0 db.FeaturePhase + var r1 error + if rf, ok := ret.Get(0).(func(db.FeaturePhase) db.FeaturePhase); ok { + r0 = rf(phase) + } else { + r0 = ret.Get(0).(db.FeaturePhase) + } + + if rf, ok := ret.Get(1).(func(db.FeaturePhase) error); ok { + r1 = rf(phase) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetPhasesByFeatureUuid provides a mock function with given fields: featureUuid +func (_m *Database) GetPhasesByFeatureUuid(featureUuid string) []db.FeaturePhase { + ret := _m.Called(featureUuid) + + var r0 []db.FeaturePhase + if rf, ok := ret.Get(0).(func(string) []db.FeaturePhase); ok { + r0 = rf(featureUuid) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.FeaturePhase) + } + } + + return r0 +} + +// GetFeaturePhaseByUuid provides a mock function with given fields: featureUuid, phaseUuid +func (_m *Database) GetFeaturePhaseByUuid(featureUuid, phaseUuid string) (db.FeaturePhase, error) { + ret := _m.Called(featureUuid, phaseUuid) + + var r0 db.FeaturePhase + var r1 error + if rf, ok := ret.Get(0).(func(string, string) db.FeaturePhase); ok { + r0 = rf(featureUuid, phaseUuid) + } else { + r0 = ret.Get(0).(db.FeaturePhase) + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(featureUuid, phaseUuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteFeaturePhase provides a mock function with given fields: featureUuid, phaseUuid +func (_m *Database) DeleteFeaturePhase(featureUuid string, phaseUuid string) error { + ret := _m.Called(featureUuid, phaseUuid) + + var r1 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r1 = rf(featureUuid, phaseUuid) + } else { + r1 = ret.Error(0) + } + + return r1 +}