Put API behind /api
This commit is contained in:
@ -24,7 +24,7 @@ func TestCreateElection(t *testing.T) {
|
||||
On("Insert", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(1, nil)
|
||||
|
||||
path := "/election"
|
||||
path := "/api/election"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -200,7 +200,7 @@ func TestCreateElection_ServerError(t *testing.T) {
|
||||
On("Insert", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(0, fmt.Errorf(""))
|
||||
|
||||
path := "/election"
|
||||
path := "/api/election"
|
||||
requestBody := api.CreateElectionRequest{
|
||||
Choices: []string{"宮本武蔵", "伊東一刀斎"},
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
@ -254,7 +254,7 @@ func TestCreateVotes_UnknownVotersElection(t *testing.T) {
|
||||
On("Insert", mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(1, nil)
|
||||
|
||||
path := "/election/1/votes"
|
||||
path := "/api/election/1/votes"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -359,7 +359,7 @@ func TestCreateVotes_KnownVotersElection(t *testing.T) {
|
||||
On("Exists", mock.Anything, mock.Anything).
|
||||
Return(false, nil)
|
||||
|
||||
path := "/election/1/votes"
|
||||
path := "/api/election/1/votes"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -467,7 +467,7 @@ func TestCreateVotes_NonExistingElection(t *testing.T) {
|
||||
On("GetById", mock.Anything).
|
||||
Return((*models.Election)(nil), sql.ErrNoRows)
|
||||
|
||||
path := "/election/1/votes"
|
||||
path := "/api/election/1/votes"
|
||||
requestBody := api.CreateVotesRequest{
|
||||
Choices: []struct {
|
||||
ChoiceText string `json:"choiceText"`
|
||||
@ -498,7 +498,7 @@ func TestCreateVotes_NonNumberElectionID(t *testing.T) {
|
||||
On("GetById", mock.Anything).
|
||||
Return((*models.Election)(nil), sql.ErrNoRows)
|
||||
|
||||
path := "/election/1a/votes"
|
||||
path := "/api/election/1a/votes"
|
||||
requestBody := api.CreateVotesRequest{
|
||||
Choices: []struct {
|
||||
ChoiceText string `json:"choiceText"`
|
||||
@ -555,8 +555,8 @@ func TestCreateVotes_AlreadyVoted(t *testing.T) {
|
||||
On("Exists", mock.Anything, mock.Anything).
|
||||
Return(true, nil)
|
||||
|
||||
knownVotersElectionPath := "/election/1/votes"
|
||||
unknownVotersElectionPath := "/election/2/votes"
|
||||
knownVotersElectionPath := "/api/election/1/votes"
|
||||
unknownVotersElectionPath := "/api/election/2/votes"
|
||||
voterIdentity := "anything"
|
||||
|
||||
tests := []struct {
|
||||
@ -640,7 +640,7 @@ func TestCreateVotes_UnknownVotersElectionMaxVotersReached(t *testing.T) {
|
||||
On("CountByElection", mock.Anything).
|
||||
Return(10, nil)
|
||||
|
||||
path := "/election/1/votes"
|
||||
path := "/api/election/1/votes"
|
||||
requestBody := api.CreateVotesRequest{
|
||||
Choices: []struct {
|
||||
ChoiceText string `json:"choiceText"`
|
||||
@ -691,7 +691,7 @@ func TestCreateVotes_ExpiredElection(t *testing.T) {
|
||||
On("CountByElection", mock.Anything).
|
||||
Return(10, nil)
|
||||
|
||||
path := "/election/1/votes"
|
||||
path := "/api/election/1/votes"
|
||||
requestBody := api.CreateVotesRequest{
|
||||
Choices: []struct {
|
||||
ChoiceText string `json:"choiceText"`
|
||||
|
@ -24,6 +24,7 @@ func (app *application) routes() http.Handler {
|
||||
|
||||
api.HandlerWithOptions(app, api.StdHTTPServerOptions{
|
||||
BaseRouter: mux,
|
||||
BaseURL: "/api",
|
||||
ErrorHandlerFunc: app.badRequestError,
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user