Test coverage issue

func (ts *service) SaveAppealAndReInspection(t *model.Profile) error {
	t.ID = bson.NewObjectId()
	t.AppealID = ts.Shared.NextCount("AppealAndReinspection")
	return ts.AppealDal.Insert(t)
}

//This is my testcase

func TestDBErrorWhileInserting(t *testing.T) {
	InsertFlag = "mongoerror"
	tempProfile := new(model.Profile)
	err := service.SaveTCAppealAndReInspection(tempProfile )
	if err == nil {
		t.Errorf("Expected DB error but got nil ")
	}
	InsertFlag = ""
	err = service.SaveTCAppealAndReInspection(tempProfile )
	if err != nil {
		t.Errorf("Expected nil but got " + err.Error())
	}
}

my code coverage is only 0.7%
where am I missing
func (ts *service) SaveAppealAndReInspection(t *model.Profile) error - returns error, so I tested wether it returns error or not.
or let me know wether I am writing wrong.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.