Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/MIDAZ-336 #364

Merged
merged 13 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ components/mdz/bin/mdz
.idea
*.iml
components/ledger/_docker-compose.yml
coverage.out
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ test:
fi
go test -v ./... ./...

cover:
@echo "$(BLUE)Generating test coverage...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
echo "$(RED)Error: go is not installed$(NC)"; \
exit 1; \
fi
go test -cover ./...

lint:
@echo "$(BLUE)Running linter and performance checks...$(NC)"
./make.sh "lint"
Expand Down Expand Up @@ -162,6 +154,14 @@ tidy:
@echo "$(BLUE)Running go mod tidy...$(NC)"
go mod tidy

cover:
@echo -e "$(BLUE)Generating test coverage...$(NC)"
@if ! command -v go >/dev/null 2>&1; then \
echo "$(RED)Error: go is not installed$(NC)"; \
exit 1; \
fi
@sh ./scripts/coverage.sh

generate-docs-all:
@echo "$(BLUE)Executing command to generate swagger...$(NC)"
$(MAKE) -C $(LEDGER_DIR) generate-docs && \
Expand Down
2 changes: 1 addition & 1 deletion components/ledger/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ runner = "green"

[misc]
# Delete tmp directory on exit
clean_on_exit = true
clean_on_exit = true
4 changes: 2 additions & 2 deletions components/ledger/internal/bootstrap/servergRPC.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package bootstrap

import (
"google.golang.org/grpc"
"net"

"google.golang.org/grpc"

"github.com/LerianStudio/midaz/pkg"
"github.com/LerianStudio/midaz/pkg/mlog"
"github.com/LerianStudio/midaz/pkg/mopentelemetry"

"github.com/pkg/errors"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package in

import (
"context"
"reflect"

"go.mongodb.org/mongo-driver/bson"
"go.opentelemetry.io/otel/trace"
"reflect"

"github.com/LerianStudio/midaz/components/transaction/internal/adapters/postgres/operation"
"github.com/LerianStudio/midaz/components/transaction/internal/adapters/postgres/transaction"
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ require (

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/miniredis/v2 v2.33.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand All @@ -65,6 +67,8 @@ require (
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-redis/redismock/v8 v8.11.5 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
Expand All @@ -78,7 +82,9 @@ require (
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
Expand Down
77 changes: 77 additions & 0 deletions go.sum

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions pkg/app_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions pkg/app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package pkg

import (
"sync"
"testing"

"github.com/LerianStudio/midaz/pkg/mlog"
gomock "go.uber.org/mock/gomock"
)

func TestWithLogger(t *testing.T) {
WithLogger(nil)
}

func TestRunApp(t *testing.T) {
RunApp("test app", nil)
}

func TestLauncher_Add(t *testing.T) {
l := &Launcher{
apps: map[string]App{
"test": nil,
},
}
l.Add("test app", nil)
}

func TestLauncherRun(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockApp := NewMockApp(ctrl)
mockApp2 := NewMockApp(ctrl)
mockLogger := mlog.NewMockLogger(ctrl)

launcherInstance := &Launcher{
apps: map[string]App{
"app1": mockApp,
"app2": mockApp2,
},
Logger: mockLogger,
wg: &sync.WaitGroup{},
}

mockLogger.EXPECT().Infof("Starting %d app(s)\n", 2).Times(1)
mockLogger.EXPECT().Info("--").Times(2)
mockLogger.EXPECT().Infof("Launcher: App \u001b[33m(%s)\u001b[0m starting\n", gomock.Any()).Times(2)
mockLogger.EXPECT().Infof("Launcher: App (%s) finished\n", gomock.Any()).Times(2)
mockLogger.EXPECT().Info("Launcher: Terminated").Times(1)

mockApp.EXPECT().Run(launcherInstance).Return(nil).Times(1)
mockApp2.EXPECT().Run(launcherInstance).Return(nil).Times(1)

launcherInstance.Run()
}

func TestNewLauncher(t *testing.T) {
t.Log(NewLauncher(func(l *Launcher) {}))
}
1 change: 1 addition & 0 deletions pkg/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pkg

import (
"context"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"

Expand Down
30 changes: 30 additions & 0 deletions pkg/context_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package pkg

import (
"context"
"testing"
)

func TestNewLoggerFromContext(t *testing.T) {
t.Log(NewLoggerFromContext(context.Background()))
}

func TestContextWithLogger(t *testing.T) {
t.Log(ContextWithLogger(context.Background(), nil))
}

func TestNewTracerFromContext(t *testing.T) {
t.Log(NewTracerFromContext(context.Background()))
}

func TestContextWithTracer(t *testing.T) {
t.Log(ContextWithTracer(context.Background(), nil))
}

func TestContextWithMidazID(t *testing.T) {
t.Log(ContextWithMidazID(context.Background(), ""))
}

func TestNewMidazIDFromContext(t *testing.T) {
t.Log(NewMidazIDFromContext(context.Background()))
}
Loading
Loading