Skip to content

Commit

Permalink
chore: ignore tests e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno committed Feb 16, 2024
1 parent 4937cd1 commit c810a79
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
run: go build -v cmd/main.go

- name: Test
run: go test -v $(go list ./... | grep -v -e "_e2e_test.go")
run: IGNORE_E2E=1 go test -v ./...
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -66,10 +67,13 @@ func (suite *AuthenticateVoterControllerTestSuite) SetupTest() {

func TestAuthenticateVoterControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(AuthenticateVoterControllerTestSuite))
}

func (suite *AuthenticateVoterControllerTestSuite) TestHandle() {
func (suite *AuthenticateVoterControllerTestSuite) TestE2EHandle() {
suite.Run("should return 200 if voter was authenticated", func() {
password, _ := di.GetContainer().Get("hasher").(*cryptography.BCryptHasher).Hash("123456")

Expand All @@ -84,7 +88,7 @@ func (suite *AuthenticateVoterControllerTestSuite) TestHandle() {
})
}

func (suite *AuthenticateVoterControllerTestSuite) TestHandleInvalidData() {
func (suite *AuthenticateVoterControllerTestSuite) TestE2EHandleInvalidData() {
suite.Run("should return 400 if voter data is not valid", func() {
suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -71,10 +72,13 @@ func (suite *CreatePollControllerTestSuite) SetupTest() {

func TestCreatePollControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(CreatePollControllerTestSuite))
}

func (suite *CreatePollControllerTestSuite) TestHandle() {
func (suite *CreatePollControllerTestSuite) TestE2EHandle() {
suite.Run("should return 201 if polls was created", func() {
userID := core.NewUniqueEntityId()

Expand All @@ -97,7 +101,7 @@ func (suite *CreatePollControllerTestSuite) TestHandle() {
})
}

// func (suite *CreatePollControllerTestSuite) TestHandleInvalidData() {
// func (suite *CreatePollControllerTestSuite) TestE2EHandleInvalidData() {
// suite.Run("should return 400 if voter data is not valid", func() {
// suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
// "email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -72,10 +73,13 @@ func (suite *FetchPollsControllerTestSuite) SetupTest() {

func TestFetchPollsControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(FetchPollsControllerTestSuite))
}

func (suite *FetchPollsControllerTestSuite) TestHandle() {
func (suite *FetchPollsControllerTestSuite) TestE2EHandle() {
suite.Run("should return a list of polls", func() {
userID := core.NewUniqueEntityId()

Expand Down Expand Up @@ -107,7 +111,7 @@ func (suite *FetchPollsControllerTestSuite) TestHandle() {
})
}

// func (suite *FetchPollsControllerTestSuite) TestHandleInvalidData() {
// func (suite *FetchPollsControllerTestSuite) TestE2EHandleInvalidData() {
// suite.Run("should return 400 if voter data is not valid", func() {
// suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
// "email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -72,10 +73,13 @@ func (suite *GetPollByIdControllerTestSuite) SetupTest() {

func TestGetPollByIdControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(GetPollByIdControllerTestSuite))
}

func (suite *GetPollByIdControllerTestSuite) TestHandle() {
func (suite *GetPollByIdControllerTestSuite) TestE2EHandle() {
suite.Run("should return a poll by id", func() {
userID := core.NewUniqueEntityId()

Expand Down Expand Up @@ -130,7 +134,7 @@ func (suite *GetPollByIdControllerTestSuite) TestHandle() {
})
}

// func (suite *GetPollByIdControllerTestSuite) TestHandleInvalidData() {
// func (suite *GetPollByIdControllerTestSuite) TestE2EHandleInvalidData() {
// suite.Run("should return 400 if voter data is not valid", func() {
// suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
// "email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -67,10 +68,13 @@ func (suite *RegisterVoterControllerTestSuite) SetupTest() {

func TestRegisterVoterControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(RegisterVoterControllerTestSuite))
}

func (suite *RegisterVoterControllerTestSuite) TestHandle() {
func (suite *RegisterVoterControllerTestSuite) TestE2EHandle() {
suite.Run("should return 204 if voter was created", func() {
suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
"name": "John Doe",
Expand All @@ -86,7 +90,7 @@ func (suite *RegisterVoterControllerTestSuite) TestHandle() {
})
}

func (suite *RegisterVoterControllerTestSuite) TestHandleInvalidData() {
func (suite *RegisterVoterControllerTestSuite) TestE2EHandleInvalidData() {
suite.Run("should return 400 if the data if not valid", func() {
suite.e.POST("/auth/register").WithJSON(map[string]interface{}{
"name": "",
Expand All @@ -96,7 +100,7 @@ func (suite *RegisterVoterControllerTestSuite) TestHandleInvalidData() {
})
}

func (suite *RegisterVoterControllerTestSuite) TestHandleVoterAlreadyExists() {
func (suite *RegisterVoterControllerTestSuite) TestE2EHandleVoterAlreadyExists() {
suite.Run("should return 409 if the voter already exists", func() {
factories.MakePrismaVoter(factories.OptionalVoterParams{
Email: "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers_test

import (
"net/http"
"os"
"testing"

"github.com/gavv/httpexpect/v2"
Expand Down Expand Up @@ -71,10 +72,13 @@ func (suite *VoteOnPollControllerTestSuite) SetupTest() {

func TestVoteOnPollControllerSuite(t *testing.T) {
// Register the test suite
if os.Getenv("IGNORE_E2E") != "" {
t.Skip("Ignorando testes E2E")
}
suite.Run(t, new(VoteOnPollControllerTestSuite))
}

func (suite *VoteOnPollControllerTestSuite) TestHandle() {
func (suite *VoteOnPollControllerTestSuite) TestE2EHandle() {
suite.Run("should return 201 if vote is created", func() {
userID := core.NewUniqueEntityId()

Expand Down Expand Up @@ -117,7 +121,7 @@ func (suite *VoteOnPollControllerTestSuite) TestHandle() {
})
}

func (suite *VoteOnPollControllerTestSuite) TestHandleWithVoteChanged() {
func (suite *VoteOnPollControllerTestSuite) TestE2EHandleWithVoteChanged() {
suite.Run("should return 201 if vote is changed", func() {
userID := core.NewUniqueEntityId()

Expand Down

0 comments on commit c810a79

Please sign in to comment.