forked from zopsmart/ezgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zopsmart#3 | Resolved merge conflicts for linter update
- Loading branch information
Showing
9 changed files
with
56 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package http | |
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"net/http" | ||
"net/http/httptest" | ||
"reflect" | ||
|
@@ -137,7 +136,6 @@ func testGetEmployeeByIDHTTP(t *testing.T, c *gofr.Context) { | |
} | ||
|
||
for i := range testcases { | ||
//req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/{%s}/employees", testcases[i].input.companyID), bytes.NewBuffer(testcases[i].input.Emp)) | ||
req := httptest.NewRequest(http.MethodGet, "/someURL/", nil) | ||
req = mux.SetURLVars(req, map[string]string{"companyID": testcases[i].input.companyID, "employeeID": testcases[i].input.employeeID}) | ||
gofrReq := gofrHTTP.NewRequest(req) | ||
|
@@ -150,7 +148,6 @@ func testGetEmployeeByIDHTTP(t *testing.T, c *gofr.Context) { | |
} | ||
|
||
func testEditEmployeeHTTP(t *testing.T, c *gofr.Context) { | ||
fmt.Println("start") | ||
type InputData struct { | ||
companyID string | ||
employeeID string | ||
|
@@ -207,11 +204,9 @@ func testEditEmployeeHTTP(t *testing.T, c *gofr.Context) { | |
c.Request = gofrReq | ||
dataHTTP := New(mockService{}) | ||
var actualOutput interface{} | ||
fmt.Println(" i is ", i) | ||
actualOutput, actualErr := dataHTTP.EditEmployee(c) | ||
CheckErrOutput(t, i, testcases[i].expectedErr, actualErr, testcases[i].expectedOutput, actualOutput) | ||
} | ||
fmt.Println("end") | ||
} | ||
|
||
func testGetAllEmployee(t *testing.T, c *gofr.Context) { | ||
|
@@ -313,7 +308,7 @@ func (m mockService) CreateEmployee(c *gofr.Context, companyID int, emp *models. | |
return models.Employee{}, customerror.ErrDBServer | ||
} | ||
|
||
func (m mockService) GetEmployeeByID(c *gofr.Context, companyID int, employeeID int) (models.Employee, error) { | ||
func (m mockService) GetEmployeeByID(c *gofr.Context, companyID, employeeID int) (models.Employee, error) { | ||
if companyID == 1 && employeeID == 1 { | ||
return models.Employee{ | ||
ID: 1, Name: "Ishan Pandey", Email: "[email protected]", Phone: 7250073079, Designation: "SDE1", YOE: 2, CompanyID: 1}, | ||
|
@@ -334,7 +329,7 @@ func (m mockService) GetAllEmployee(c *gofr.Context, companyID int, queryParams | |
return nil, customerror.ErrDBServer | ||
} | ||
|
||
func (m mockService) EditEmployee(c *gofr.Context, companyID int, employeeID int, emp *models.Employee) (models.Employee, error) { | ||
func (m mockService) EditEmployee(c *gofr.Context, companyID, employeeID int, emp *models.Employee) (models.Employee, error) { | ||
if companyID == 1 && employeeID == 3 { | ||
return models.Employee{ | ||
ID: 3, Name: "Ishanx Pandey", Email: "[email protected]", Phone: 7250073079, Designation: "SDE1", YOE: 2, CompanyID: 1}, | ||
|
@@ -344,6 +339,6 @@ func (m mockService) EditEmployee(c *gofr.Context, companyID int, employeeID int | |
return models.Employee{}, customerror.ErrDBServer | ||
} | ||
|
||
func (m mockService) DeleteEmployee(c *gofr.Context, companyID int, employeeID int) error { | ||
func (m mockService) DeleteEmployee(c *gofr.Context, companyID, employeeID int) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ func TestServiceLayer(t *testing.T) { | |
} | ||
|
||
func testAllEmployeeService(t *testing.T, c *gofr.Context) { | ||
testCases := []struct { | ||
var testCases = []struct { | ||
input int | ||
expectedOutput []models.Employee | ||
expectedErr error | ||
|
@@ -92,7 +92,6 @@ func testAllEmployeeService(t *testing.T, c *gofr.Context) { | |
}, | ||
}, | ||
} | ||
|
||
for i := range testCases { | ||
dataService := New(mockStore{}) | ||
output, err := dataService.GetAllEmployee(c, testCases[i].input, testCases[i].queryParams) | ||
|
@@ -241,7 +240,6 @@ func testEditEmployeeService(t *testing.T, c *gofr.Context) { | |
CheckErrOutput(t, testCases[i].expectedErr, err, testCases[i].expectedOutput, output) | ||
} | ||
} | ||
|
||
func testDeleteEmployeeService(t *testing.T, c *gofr.Context) { | ||
type InputData struct { | ||
companyID int | ||
|
@@ -299,11 +297,9 @@ func (m mockStore) GetAllEmployeeWithoutDesignation(c *gofr.Context, companyID i | |
if companyID == 2 { | ||
return nil, customerror.ErrDBServer | ||
} | ||
|
||
res := []models.Employee{{1, "Bittu", "[email protected]", 7250073079, "sde1", 2, 1}, | ||
{2, "Bittu Ray", "[email protected]", 7250073080, "sde2", 2, 1}, | ||
} | ||
|
||
return res, nil | ||
} | ||
|
||
|
@@ -314,7 +310,6 @@ func (m mockStore) GetEmployeeByID(c *gofr.Context, companyID, employeeID int) ( | |
if companyID != employeeID { | ||
return models.Employee{}, customerror.ErrRecordNotFound | ||
} | ||
|
||
return models.Employee{}, nil | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.