Skip to content

Commit

Permalink
Replace time in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ofalvai committed Nov 14, 2023
1 parent 10325f2 commit 83e12f8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions _tests/integration/log_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,12 @@ func convertBitriseStartedEventLog(line []byte) (string, error) {
}

var buf bytes.Buffer
logger := log.NewLogger(log.LoggerOpts{LoggerType: log.ConsoleLogger, Writer: &buf, TimeProvider: referenceTime})
logger := log.NewLogger(log.LoggerOpts{LoggerType: log.ConsoleLogger, Writer: &buf, TimeProvider: time.Now})
logger.PrintBitriseStartedEvent(eventLog.Content)

return buf.String(), nil
}

func referenceTime() time.Time {
return time.Date(2022, 1, 1, 1, 1, 1, 0, time.UTC)
}

func convertStepStartedEventLog(line []byte) (string, error) {
if !strings.Contains(string(line), "\"event_type\":\"step_started\"") {
return "", fmt.Errorf("not a step started event")
Expand Down Expand Up @@ -265,5 +261,8 @@ func replaceVariableParts(line string) string {
totalRunTimeRegexp := regexp.MustCompile(`(\| Total runtime: .+ \|)`)
line = totalRunTimeRegexp.ReplaceAllString(line, "[REPLACED]")

invocationStartRegexp := regexp.MustCompile(`(\| Invocation started at .+)`)
line = invocationStartRegexp.ReplaceAllString(line, "[REPLACED]")

return line
}

0 comments on commit 83e12f8

Please sign in to comment.