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 a72e204
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions services/frontend-service/pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,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 fmt.Errorf(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 fmt.Errorf(msg)
}

var jwks *keyfunc.JWKS = nil
Expand Down

0 comments on commit a72e204

Please sign in to comment.