Skip to content

Commit

Permalink
refactor: add driver provider
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofnds committed Sep 21, 2023
1 parent f9ce187 commit bd9fa69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions test/driver/driver.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package driver

import (
apphttp "app/adapter/http"
"encoding/json"
"fmt"
"io"
"net/http"

"go.uber.org/fx"
)

var Provider = fx.Provide(func(config apphttp.Config) *Driver {
return NewDriver(fmt.Sprintf("http://localhost:%d", config.Port))
})

type Driver struct {
URL string
User *UserDriver
Expand Down
8 changes: 2 additions & 6 deletions user/http/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package http_test

import (
"context"
"fmt"
"net/http"
"testing"

Expand Down Expand Up @@ -40,14 +39,13 @@ var _ = Describe("/users", Ordered, func() {
)

BeforeAll(func() {
var httpConfig apphttp.Config

fxApp = fxtest.New(
GinkgoT(),
logger.NopLoggerProvider,
test.Queue,
test.Transaction,
test.AvailablePortProvider,
driver.Provider,
config.Module,
featureflags.Module,
apphttp.FiberModule,
Expand All @@ -57,10 +55,8 @@ var _ = Describe("/users", Ordered, func() {
fx.Invoke(func(app *fiber.App, controller *userhttp.Controller) {
controller.Register(app)
}),
fx.Populate(&httpConfig, &userService),
fx.Populate(&app, &userService),
).RequireStart()

app = driver.NewDriver(fmt.Sprintf("http://localhost:%d", httpConfig.Port))
})

BeforeEach(func() { Must(userService.DeleteAll(context.Background())) })
Expand Down

0 comments on commit bd9fa69

Please sign in to comment.