Skip to content

Commit

Permalink
Fixing the broken tests due to new setupRoutes(..) signature
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgomes28 committed Apr 29, 2024
1 parent a725a85 commit 74a3c69
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
21 changes: 11 additions & 10 deletions tests/admin_app_tests/endpoint_tests/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/matheusgomes28/urchin/tests/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
lua "github.com/yuin/gopher-lua"
)

type imageResponse struct {
Expand All @@ -32,7 +33,7 @@ func TestPostImage(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
w := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -68,7 +69,7 @@ func TestPostImageNotAnImageFile(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
w := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -99,7 +100,7 @@ func TestPostImageWrongFileContentType(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
w := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -132,7 +133,7 @@ func TestPostImageFailedToCreateDatabaseEntry(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
w := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -173,7 +174,7 @@ func TestGetImage(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
post_recorder := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -220,7 +221,7 @@ func TestGetImageNoDatabaseEntry(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))

get_recorder := httptest.NewRecorder()
uuid, _ := uuid.New()
Expand All @@ -239,7 +240,7 @@ func TestGetImageNoImageFile(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))

get_recorder := httptest.NewRecorder()
uuid, _ := uuid.New()
Expand Down Expand Up @@ -271,7 +272,7 @@ func TestDeleteImage(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
post_recorder := httptest.NewRecorder()

pr, pw := io.Pipe()
Expand Down Expand Up @@ -323,7 +324,7 @@ func TestDeleteImageNoDatabaseEntry(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
delete_recorder := httptest.NewRecorder()

uuid, _ := uuid.New()
Expand All @@ -350,7 +351,7 @@ func TestDeleteImageNoImageFile(t *testing.T) {
},
}

r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
delete_recorder := httptest.NewRecorder()

uuid, _ := uuid.New()
Expand Down
3 changes: 2 additions & 1 deletion tests/admin_app_tests/endpoint_tests/posts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/matheusgomes28/urchin/common"
"github.com/matheusgomes28/urchin/tests/mocks"
"github.com/stretchr/testify/assert"
lua "github.com/yuin/gopher-lua"
)

type postRequest struct {
Expand All @@ -36,7 +37,7 @@ var app_settings = common.AppSettings{
func TestIndexPing(t *testing.T) {

database_mock := mocks.DatabaseMock{}
r := admin_app.SetupRoutes(app_settings, database_mock)
r := admin_app.SetupRoutes(app_settings, database_mock, make(map[string]*lua.LState))
w := httptest.NewRecorder()

request := postRequest{
Expand Down
3 changes: 2 additions & 1 deletion tests/system_tests/admin_app/endpoint_tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
lua "github.com/yuin/gopher-lua"

admin_app "github.com/matheusgomes28/urchin/admin-app"
"github.com/matheusgomes28/urchin/tests/helpers"
Expand Down Expand Up @@ -56,7 +57,7 @@ func TestImageUpload(t *testing.T) {

// Execute multiform request
post_recorder := httptest.NewRecorder()
r := admin_app.SetupRoutes(app_settings, database)
r := admin_app.SetupRoutes(app_settings, database, make(map[string]*lua.LState))
require.Nil(t, err)

req, _ := http.NewRequest("POST", "/images", pr)
Expand Down
3 changes: 2 additions & 1 deletion tests/system_tests/admin_app/endpoint_tests/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
lua "github.com/yuin/gopher-lua"

admin_app "github.com/matheusgomes28/urchin/admin-app"
"github.com/matheusgomes28/urchin/tests/helpers"
Expand Down Expand Up @@ -42,7 +43,7 @@ func TestPostExists(t *testing.T) {
}

w := httptest.NewRecorder()
r := admin_app.SetupRoutes(app_settings, database)
r := admin_app.SetupRoutes(app_settings, database, make(map[string]*lua.LState))
request_bytes, err := json.Marshal(add_post_request)
require.Nil(t, err)
req, _ := http.NewRequest("POST", "/posts", bytes.NewBuffer(request_bytes))
Expand Down

0 comments on commit 74a3c69

Please sign in to comment.