Skip to content

Commit

Permalink
Fix server_test in frontend-service
Browse files Browse the repository at this point in the history
The function runServer used the Fatal function of the zap logger.
This has really unfortunate results in tests: You cannot see any details, except the name of the test and that it failed
Instead we should always log with "Error" and then return the error (or only return the error)
  • Loading branch information
sven-urbanski-freiheit-com committed Oct 24, 2023
1 parent 31659ac commit 98fe92b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions services/frontend-service/pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd

import (
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -77,16 +78,21 @@ func RunServer() {

func runServer(ctx context.Context) error {
err := envconfig.Process("kuberpult", &c)

if err != nil {
logger.FromContext(ctx).Fatal("config.parse", zap.Error(err))
logger.FromContext(ctx).Error("config.parse", zap.Error(err))
return err
}
logger.FromContext(ctx).Warn(fmt.Sprintf("config: \n%v", c))
if c.GitAuthorEmail == "" {
logger.FromContext(ctx).Fatal("DefaultGitAuthorEmail must not be empty")
msg := "DefaultGitAuthorEmail must not be empty"
logger.FromContext(ctx).Error(msg)
return errors.New(msg)
}
if c.GitAuthorName == "" {
logger.FromContext(ctx).Fatal("DefaultGitAuthorName must not be empty")
msg := "DefaultGitAuthorName must not be empty"
logger.FromContext(ctx).Error(msg)
return errors.New(msg)
}

var jwks *keyfunc.JWKS = nil
Expand Down

0 comments on commit 98fe92b

Please sign in to comment.