Refactor logging

This commit is contained in:
Alexander
2026-05-07 16:50:40 +02:00
parent fb2e4b9107
commit 3d111f9008
14 changed files with 683 additions and 58 deletions
+12 -1
View File
@@ -9,7 +9,9 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/metadata-agregator/internal/provider/musicbrainz"
"github.com/metadata-agregator/internal/server"
"github.com/metadata-agregator/internal/service"
metadatav1 "github.com/metadata-agregator/pkg/gen/metadata/v1"
)
@@ -32,8 +34,17 @@ func startTestServer(t *testing.T) *testServer {
t.Fatalf("failed to listen: %v", err)
}
mb := musicbrainz.New()
noopArtist := &noopArtistRepo{}
noopAlbum := &noopAlbumRepo{}
noopTrack := &noopTrackRepo{}
svc := service.NewMetadataService(noopArtist, noopAlbum, noopTrack, mb)
services := map[metadatav1.Provider]*service.MetadataService{
metadatav1.Provider_PROVIDER_MUSICBRAINZ: svc,
}
grpcServer := grpc.NewServer()
metadatav1.RegisterMetadataServiceServer(grpcServer, server.NewMetadataServer())
metadatav1.RegisterMetadataServiceServer(grpcServer, server.NewMetadataServer(services))
go func() {
if err := grpcServer.Serve(lis); err != nil {
+66
View File
@@ -0,0 +1,66 @@
package e2e
import (
"context"
"github.com/metadata-agregator/internal/domain"
"github.com/metadata-agregator/internal/repository"
)
type noopArtistRepo struct{}
func (r *noopArtistRepo) GetByID(ctx context.Context, id string) (*domain.Artist, error) {
return nil, repository.ErrNotFound
}
func (r *noopArtistRepo) GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Artist, error) {
return nil, repository.ErrNotFound
}
func (r *noopArtistRepo) Search(ctx context.Context, query string, limit, offset int) (*domain.SearchResult[domain.Artist], error) {
return &domain.SearchResult[domain.Artist]{}, nil
}
func (r *noopArtistRepo) Save(ctx context.Context, artist *domain.Artist) error {
return nil
}
type noopAlbumRepo struct{}
func (r *noopAlbumRepo) GetByID(ctx context.Context, id string) (*domain.Album, error) {
return nil, repository.ErrNotFound
}
func (r *noopAlbumRepo) GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Album, error) {
return nil, repository.ErrNotFound
}
func (r *noopAlbumRepo) GetByArtistID(ctx context.Context, artistID string, limit, offset int) (*domain.SearchResult[domain.Album], error) {
return &domain.SearchResult[domain.Album]{}, nil
}
func (r *noopAlbumRepo) Save(ctx context.Context, album *domain.Album) error {
return nil
}
type noopTrackRepo struct{}
func (r *noopTrackRepo) GetByID(ctx context.Context, id string) (*domain.Track, error) {
return nil, repository.ErrNotFound
}
func (r *noopTrackRepo) GetByExternalID(ctx context.Context, source, sourceID string) (*domain.Track, error) {
return nil, repository.ErrNotFound
}
func (r *noopTrackRepo) GetByISRC(ctx context.Context, isrc string) (*domain.Track, error) {
return nil, repository.ErrNotFound
}
func (r *noopTrackRepo) GetByAlbumID(ctx context.Context, albumID string) ([]domain.Track, error) {
return nil, nil
}
func (r *noopTrackRepo) Save(ctx context.Context, track *domain.Track) error {
return nil
}