Skip to content

Commit

Permalink
clean problematic fields when copying run (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored Jun 2, 2022
1 parent d7fa469 commit e54fb48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/http/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *controller) RerunTestRun(ctx context.Context, testID string, runID stri
return handleDBError(err), err
}

newTestRun, err := c.testDB.CreateRun(ctx, test, run.Copy(test.Version))
newTestRun, err := c.testDB.CreateRun(ctx, test, run.Copy())
if err != nil {
return openapi.Response(http.StatusUnprocessableEntity, err.Error()), err
}
Expand Down
10 changes: 8 additions & 2 deletions server/model/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math"
"time"

"github.com/google/uuid"
"github.com/kubeshop/tracetest/server/traces"
)

Expand All @@ -13,9 +14,14 @@ var (
}
)

func (r Run) Copy(testVersion int) Run {
func (r Run) Copy() Run {
r.ID = uuid.UUID{}
r.Results = nil
r.TestVersion = testVersion
r.CreatedAt = Now()
r.ServiceTriggeredAt = time.Time{}
r.ServiceTriggerCompletedAt = time.Time{}
r.ObtainedTraceAt = time.Time{}
r.CompletedAt = time.Time{}

return r
}
Expand Down

0 comments on commit e54fb48

Please sign in to comment.