Skip to content

Commit

Permalink
💚 Fix CI Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wjuniorbh92 committed Nov 1, 2023
1 parent 432498e commit 58a8e4b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
4 changes: 2 additions & 2 deletions backend/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func Run(cfg *config.Config, pg *postgres.Postgres, pKp, pHor, pEnv entity.Produ

select {
case s := <-interrupt:
l.Warn("app - Run - signal.Notify", s)
l.Warn(s.String())
case err := <-httpServer.Notify():
l.Warn("app - Run - httpServer.Notify", err)
l.Error(err.Error())
}

// Shutdown
Expand Down
24 changes: 16 additions & 8 deletions backend/internal/controller/http/v1/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,12 @@ func (r *assetsRoutes) mintAsset(c *gin.Context) {
}

sponsorID := request.SponsorId
var err error
if sponsorID == 0 {
sponsorID = _sponsorId
_, err = r.w.Get(_sponsorId)
} else {
_, err = r.w.Get(request.SponsorId)
}
_, err := r.w.Get(request.SponsorId)
if err != nil {
r.logger.Error(err, "http - v1 - mint asset - get sponsor")
errorResponse(c, http.StatusNotFound, "sponsor wallet not found", err)
Expand Down Expand Up @@ -450,9 +452,10 @@ func (r *assetsRoutes) burnAsset(c *gin.Context) {

sponsorID := request.SponsorId
if sponsorID == 0 {
sponsorID = _sponsorId
_, err = r.w.Get(_sponsorId)
} else {
_, err = r.w.Get(request.SponsorId)
}
_, err = r.w.Get(request.SponsorId)
if err != nil {
r.logger.Error(err, "http - v1 - burn asset - get sponsor")
errorResponse(c, http.StatusNotFound, "sponsor wallet not found", err)
Expand Down Expand Up @@ -548,9 +551,10 @@ func (r *assetsRoutes) transferAsset(c *gin.Context) {

sponsorID := request.SponsorId
if sponsorID == 0 {
sponsorID = _sponsorId
_, err = r.w.Get(_sponsorId)
} else {
_, err = r.w.Get(request.SponsorId)
}
_, err = r.w.Get(request.SponsorId)
if err != nil {
r.logger.Error(err, "http - v1 - transfer asset - get sponsor")
errorResponse(c, http.StatusNotFound, "sponsor wallet not found", err)
Expand Down Expand Up @@ -645,10 +649,14 @@ func (r *assetsRoutes) clawbackAsset(c *gin.Context) {
}

sponsorID := request.SponsorId
var sponsor entity.Wallet
var err error
if sponsorID == 0 {
sponsorID = _sponsorId
sponsor, err = r.w.Get(_sponsorId)
} else {
sponsor, err = r.w.Get(request.SponsorId)
}
sponsor, err := r.w.Get(request.SponsorId)

if err != nil {
r.logger.Error(err, "http - v1 - clawback asset - get sponsor")
errorResponse(c, http.StatusNotFound, "sponsor wallet not found", err)
Expand Down
5 changes: 4 additions & 1 deletion backend/internal/controller/http/v1/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func newMockProducer() *mockProducer {

func (p *mockProducer) Produce(key string, value interface{}) error {
go func() {
notify.Post(key, mockResponse)
err := notify.Post(key, mockResponse)
if err != nil {
panic(err)
}
}()
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion backend/internal/usecase/repo/toml_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func (r TomlRepoInterface) CreateToml(content string) (string, error) {
func (r TomlRepoInterface) GetToml() (string, error) {
var res string
stmt := `SELECT content FROM toml ORDER BY id DESC LIMIT 1;`
r.Db.QueryRow(stmt).Scan(&res)
err := r.Db.QueryRow(stmt).Scan(&res)
if err != nil {
return "", fmt.Errorf("AssetRepo - GetToml - db.QueryRow: %w", err)
}

return res, nil
}
20 changes: 9 additions & 11 deletions backend/internal/usecase/repo/user_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@ func New(pg *postgres.Postgres) UserRepo {
}

func (r UserRepo) GetUser(email string) (entity.User, error) {
stmt := fmt.Sprintf(`SELECT ID, Name, Password, role_id, Email FROM UserAccount WHERE email='%s'`, email)
stmt := fmt.Sprintf(`SELECT ID, Name, Password, role_id, Email FROM UserAccount WHERE email='%s' LIMIT 1`, email)

rows, err := r.Db.Query(stmt)
if err != nil {
return entity.User{}, fmt.Errorf("UserRepo - GetUser - db.Query: %w", err)
}

defer rows.Close()

for rows.Next() {
var user entity.User

err = rows.Scan(&user.ID, &user.Name, &user.Password, &user.RoleId, &user.Email)
if err != nil {
return entity.User{}, fmt.Errorf("UserRepo - GetUser - rows.Scan: %w", err)
}
if !rows.Next() {
return entity.User{}, nil // No matching user found.
}

return user, nil
var user entity.User
err = rows.Scan(&user.ID, &user.Name, &user.Password, &user.RoleId, &user.Email)
if err != nil {
return entity.User{}, fmt.Errorf("UserRepo - GetUser - rows.Scan: %w", err)
}

return entity.User{}, nil
return user, nil
}

func (r UserRepo) CreateUser(user entity.User) error {
Expand Down
5 changes: 4 additions & 1 deletion backend/pkg/kafka/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func TestAttemptConnect(t *testing.T) {
Value: []byte(value),
Headers: []kafka.Header{{Key: "Transaction.Type", Value: []byte("CreatePayment")}},
}, deliveryChan)

if err != nil {
// Handle the error appropriately
log.Fatalf("Failed to produce message: %v", err)
}
e := <-deliveryChan
m := e.(*kafka.Message)

Expand Down

0 comments on commit 58a8e4b

Please sign in to comment.