Skip to content

Commit

Permalink
fix: set mock logger to trace level and job config tests to check the…
Browse files Browse the repository at this point in the history
… log output
  • Loading branch information
FMotalleb committed Jun 16, 2024
1 parent c81362b commit 5e50e1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions config/job_config_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import (
)

func TestJobConfig_Validate_Disabled(t *testing.T) {
logger, _ := mocklogger.HijackOutput(logrus.New())
logger, buff := mocklogger.HijackOutput(logrus.New())
log := logrus.NewEntry(logger)
jobConfig := &config.JobConfig{
Disabled: true,
Disabled: true,
Name: "Test",
Concurrency: 35,
Tasks: []config.Task{{}},
Events: []config.JobEvent{
{Interval: -1}, // Invalid interval
},
}

err := jobConfig.Validate(log)
assert.NoError(t, err, "Expected no error when job is disabled")
assert.Contains(t, buff.String(), "JobConfig Test is disabled")
}

func TestJobConfig_Validate_Events(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions logger/mock_logger/mock_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func HijackOutput(log *logrus.Logger) (*logrus.Logger, *bytes.Buffer) {
buffer := bytes.NewBuffer([]byte{})
log.SetLevel(logrus.TraceLevel)
log.SetOutput(buffer)
return log, buffer
}

0 comments on commit 5e50e1e

Please sign in to comment.