// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/buildbarn/bb-portal/ent/gen/ent/predicate"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testcollection"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testfile"
	"github.com/buildbarn/bb-portal/ent/gen/ent/testsummary"
)

// TestSummaryUpdate is the builder for updating TestSummary entities.
type TestSummaryUpdate struct {
	config
	hooks    []Hook
	mutation *TestSummaryMutation
}

// Where appends a list predicates to the TestSummaryUpdate builder.
func (tsu *TestSummaryUpdate) Where(ps ...predicate.TestSummary) *TestSummaryUpdate {
	tsu.mutation.Where(ps...)
	return tsu
}

// SetOverallStatus sets the "overall_status" field.
func (tsu *TestSummaryUpdate) SetOverallStatus(ts testsummary.OverallStatus) *TestSummaryUpdate {
	tsu.mutation.SetOverallStatus(ts)
	return tsu
}

// SetNillableOverallStatus sets the "overall_status" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableOverallStatus(ts *testsummary.OverallStatus) *TestSummaryUpdate {
	if ts != nil {
		tsu.SetOverallStatus(*ts)
	}
	return tsu
}

// ClearOverallStatus clears the value of the "overall_status" field.
func (tsu *TestSummaryUpdate) ClearOverallStatus() *TestSummaryUpdate {
	tsu.mutation.ClearOverallStatus()
	return tsu
}

// SetTotalRunCount sets the "total_run_count" field.
func (tsu *TestSummaryUpdate) SetTotalRunCount(i int32) *TestSummaryUpdate {
	tsu.mutation.ResetTotalRunCount()
	tsu.mutation.SetTotalRunCount(i)
	return tsu
}

// SetNillableTotalRunCount sets the "total_run_count" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableTotalRunCount(i *int32) *TestSummaryUpdate {
	if i != nil {
		tsu.SetTotalRunCount(*i)
	}
	return tsu
}

// AddTotalRunCount adds i to the "total_run_count" field.
func (tsu *TestSummaryUpdate) AddTotalRunCount(i int32) *TestSummaryUpdate {
	tsu.mutation.AddTotalRunCount(i)
	return tsu
}

// ClearTotalRunCount clears the value of the "total_run_count" field.
func (tsu *TestSummaryUpdate) ClearTotalRunCount() *TestSummaryUpdate {
	tsu.mutation.ClearTotalRunCount()
	return tsu
}

// SetRunCount sets the "run_count" field.
func (tsu *TestSummaryUpdate) SetRunCount(i int32) *TestSummaryUpdate {
	tsu.mutation.ResetRunCount()
	tsu.mutation.SetRunCount(i)
	return tsu
}

// SetNillableRunCount sets the "run_count" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableRunCount(i *int32) *TestSummaryUpdate {
	if i != nil {
		tsu.SetRunCount(*i)
	}
	return tsu
}

// AddRunCount adds i to the "run_count" field.
func (tsu *TestSummaryUpdate) AddRunCount(i int32) *TestSummaryUpdate {
	tsu.mutation.AddRunCount(i)
	return tsu
}

// ClearRunCount clears the value of the "run_count" field.
func (tsu *TestSummaryUpdate) ClearRunCount() *TestSummaryUpdate {
	tsu.mutation.ClearRunCount()
	return tsu
}

// SetAttemptCount sets the "attempt_count" field.
func (tsu *TestSummaryUpdate) SetAttemptCount(i int32) *TestSummaryUpdate {
	tsu.mutation.ResetAttemptCount()
	tsu.mutation.SetAttemptCount(i)
	return tsu
}

// SetNillableAttemptCount sets the "attempt_count" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableAttemptCount(i *int32) *TestSummaryUpdate {
	if i != nil {
		tsu.SetAttemptCount(*i)
	}
	return tsu
}

// AddAttemptCount adds i to the "attempt_count" field.
func (tsu *TestSummaryUpdate) AddAttemptCount(i int32) *TestSummaryUpdate {
	tsu.mutation.AddAttemptCount(i)
	return tsu
}

// ClearAttemptCount clears the value of the "attempt_count" field.
func (tsu *TestSummaryUpdate) ClearAttemptCount() *TestSummaryUpdate {
	tsu.mutation.ClearAttemptCount()
	return tsu
}

// SetShardCount sets the "shard_count" field.
func (tsu *TestSummaryUpdate) SetShardCount(i int32) *TestSummaryUpdate {
	tsu.mutation.ResetShardCount()
	tsu.mutation.SetShardCount(i)
	return tsu
}

// SetNillableShardCount sets the "shard_count" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableShardCount(i *int32) *TestSummaryUpdate {
	if i != nil {
		tsu.SetShardCount(*i)
	}
	return tsu
}

// AddShardCount adds i to the "shard_count" field.
func (tsu *TestSummaryUpdate) AddShardCount(i int32) *TestSummaryUpdate {
	tsu.mutation.AddShardCount(i)
	return tsu
}

// ClearShardCount clears the value of the "shard_count" field.
func (tsu *TestSummaryUpdate) ClearShardCount() *TestSummaryUpdate {
	tsu.mutation.ClearShardCount()
	return tsu
}

// SetTotalNumCached sets the "total_num_cached" field.
func (tsu *TestSummaryUpdate) SetTotalNumCached(i int32) *TestSummaryUpdate {
	tsu.mutation.ResetTotalNumCached()
	tsu.mutation.SetTotalNumCached(i)
	return tsu
}

// SetNillableTotalNumCached sets the "total_num_cached" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableTotalNumCached(i *int32) *TestSummaryUpdate {
	if i != nil {
		tsu.SetTotalNumCached(*i)
	}
	return tsu
}

// AddTotalNumCached adds i to the "total_num_cached" field.
func (tsu *TestSummaryUpdate) AddTotalNumCached(i int32) *TestSummaryUpdate {
	tsu.mutation.AddTotalNumCached(i)
	return tsu
}

// ClearTotalNumCached clears the value of the "total_num_cached" field.
func (tsu *TestSummaryUpdate) ClearTotalNumCached() *TestSummaryUpdate {
	tsu.mutation.ClearTotalNumCached()
	return tsu
}

// SetFirstStartTime sets the "first_start_time" field.
func (tsu *TestSummaryUpdate) SetFirstStartTime(i int64) *TestSummaryUpdate {
	tsu.mutation.ResetFirstStartTime()
	tsu.mutation.SetFirstStartTime(i)
	return tsu
}

// SetNillableFirstStartTime sets the "first_start_time" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableFirstStartTime(i *int64) *TestSummaryUpdate {
	if i != nil {
		tsu.SetFirstStartTime(*i)
	}
	return tsu
}

// AddFirstStartTime adds i to the "first_start_time" field.
func (tsu *TestSummaryUpdate) AddFirstStartTime(i int64) *TestSummaryUpdate {
	tsu.mutation.AddFirstStartTime(i)
	return tsu
}

// ClearFirstStartTime clears the value of the "first_start_time" field.
func (tsu *TestSummaryUpdate) ClearFirstStartTime() *TestSummaryUpdate {
	tsu.mutation.ClearFirstStartTime()
	return tsu
}

// SetLastStopTime sets the "last_stop_time" field.
func (tsu *TestSummaryUpdate) SetLastStopTime(i int64) *TestSummaryUpdate {
	tsu.mutation.ResetLastStopTime()
	tsu.mutation.SetLastStopTime(i)
	return tsu
}

// SetNillableLastStopTime sets the "last_stop_time" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableLastStopTime(i *int64) *TestSummaryUpdate {
	if i != nil {
		tsu.SetLastStopTime(*i)
	}
	return tsu
}

// AddLastStopTime adds i to the "last_stop_time" field.
func (tsu *TestSummaryUpdate) AddLastStopTime(i int64) *TestSummaryUpdate {
	tsu.mutation.AddLastStopTime(i)
	return tsu
}

// ClearLastStopTime clears the value of the "last_stop_time" field.
func (tsu *TestSummaryUpdate) ClearLastStopTime() *TestSummaryUpdate {
	tsu.mutation.ClearLastStopTime()
	return tsu
}

// SetTotalRunDuration sets the "total_run_duration" field.
func (tsu *TestSummaryUpdate) SetTotalRunDuration(i int64) *TestSummaryUpdate {
	tsu.mutation.ResetTotalRunDuration()
	tsu.mutation.SetTotalRunDuration(i)
	return tsu
}

// SetNillableTotalRunDuration sets the "total_run_duration" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableTotalRunDuration(i *int64) *TestSummaryUpdate {
	if i != nil {
		tsu.SetTotalRunDuration(*i)
	}
	return tsu
}

// AddTotalRunDuration adds i to the "total_run_duration" field.
func (tsu *TestSummaryUpdate) AddTotalRunDuration(i int64) *TestSummaryUpdate {
	tsu.mutation.AddTotalRunDuration(i)
	return tsu
}

// ClearTotalRunDuration clears the value of the "total_run_duration" field.
func (tsu *TestSummaryUpdate) ClearTotalRunDuration() *TestSummaryUpdate {
	tsu.mutation.ClearTotalRunDuration()
	return tsu
}

// SetLabel sets the "label" field.
func (tsu *TestSummaryUpdate) SetLabel(s string) *TestSummaryUpdate {
	tsu.mutation.SetLabel(s)
	return tsu
}

// SetNillableLabel sets the "label" field if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableLabel(s *string) *TestSummaryUpdate {
	if s != nil {
		tsu.SetLabel(*s)
	}
	return tsu
}

// ClearLabel clears the value of the "label" field.
func (tsu *TestSummaryUpdate) ClearLabel() *TestSummaryUpdate {
	tsu.mutation.ClearLabel()
	return tsu
}

// SetTestCollectionID sets the "test_collection" edge to the TestCollection entity by ID.
func (tsu *TestSummaryUpdate) SetTestCollectionID(id int) *TestSummaryUpdate {
	tsu.mutation.SetTestCollectionID(id)
	return tsu
}

// SetNillableTestCollectionID sets the "test_collection" edge to the TestCollection entity by ID if the given value is not nil.
func (tsu *TestSummaryUpdate) SetNillableTestCollectionID(id *int) *TestSummaryUpdate {
	if id != nil {
		tsu = tsu.SetTestCollectionID(*id)
	}
	return tsu
}

// SetTestCollection sets the "test_collection" edge to the TestCollection entity.
func (tsu *TestSummaryUpdate) SetTestCollection(t *TestCollection) *TestSummaryUpdate {
	return tsu.SetTestCollectionID(t.ID)
}

// AddPassedIDs adds the "passed" edge to the TestFile entity by IDs.
func (tsu *TestSummaryUpdate) AddPassedIDs(ids ...int) *TestSummaryUpdate {
	tsu.mutation.AddPassedIDs(ids...)
	return tsu
}

// AddPassed adds the "passed" edges to the TestFile entity.
func (tsu *TestSummaryUpdate) AddPassed(t ...*TestFile) *TestSummaryUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsu.AddPassedIDs(ids...)
}

// AddFailedIDs adds the "failed" edge to the TestFile entity by IDs.
func (tsu *TestSummaryUpdate) AddFailedIDs(ids ...int) *TestSummaryUpdate {
	tsu.mutation.AddFailedIDs(ids...)
	return tsu
}

// AddFailed adds the "failed" edges to the TestFile entity.
func (tsu *TestSummaryUpdate) AddFailed(t ...*TestFile) *TestSummaryUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsu.AddFailedIDs(ids...)
}

// Mutation returns the TestSummaryMutation object of the builder.
func (tsu *TestSummaryUpdate) Mutation() *TestSummaryMutation {
	return tsu.mutation
}

// ClearTestCollection clears the "test_collection" edge to the TestCollection entity.
func (tsu *TestSummaryUpdate) ClearTestCollection() *TestSummaryUpdate {
	tsu.mutation.ClearTestCollection()
	return tsu
}

// ClearPassed clears all "passed" edges to the TestFile entity.
func (tsu *TestSummaryUpdate) ClearPassed() *TestSummaryUpdate {
	tsu.mutation.ClearPassed()
	return tsu
}

// RemovePassedIDs removes the "passed" edge to TestFile entities by IDs.
func (tsu *TestSummaryUpdate) RemovePassedIDs(ids ...int) *TestSummaryUpdate {
	tsu.mutation.RemovePassedIDs(ids...)
	return tsu
}

// RemovePassed removes "passed" edges to TestFile entities.
func (tsu *TestSummaryUpdate) RemovePassed(t ...*TestFile) *TestSummaryUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsu.RemovePassedIDs(ids...)
}

// ClearFailed clears all "failed" edges to the TestFile entity.
func (tsu *TestSummaryUpdate) ClearFailed() *TestSummaryUpdate {
	tsu.mutation.ClearFailed()
	return tsu
}

// RemoveFailedIDs removes the "failed" edge to TestFile entities by IDs.
func (tsu *TestSummaryUpdate) RemoveFailedIDs(ids ...int) *TestSummaryUpdate {
	tsu.mutation.RemoveFailedIDs(ids...)
	return tsu
}

// RemoveFailed removes "failed" edges to TestFile entities.
func (tsu *TestSummaryUpdate) RemoveFailed(t ...*TestFile) *TestSummaryUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsu.RemoveFailedIDs(ids...)
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (tsu *TestSummaryUpdate) Save(ctx context.Context) (int, error) {
	return withHooks(ctx, tsu.sqlSave, tsu.mutation, tsu.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (tsu *TestSummaryUpdate) SaveX(ctx context.Context) int {
	affected, err := tsu.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

// Exec executes the query.
func (tsu *TestSummaryUpdate) Exec(ctx context.Context) error {
	_, err := tsu.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (tsu *TestSummaryUpdate) ExecX(ctx context.Context) {
	if err := tsu.Exec(ctx); err != nil {
		panic(err)
	}
}

// check runs all checks and user-defined validators on the builder.
func (tsu *TestSummaryUpdate) check() error {
	if v, ok := tsu.mutation.OverallStatus(); ok {
		if err := testsummary.OverallStatusValidator(v); err != nil {
			return &ValidationError{Name: "overall_status", err: fmt.Errorf(`ent: validator failed for field "TestSummary.overall_status": %w`, err)}
		}
	}
	return nil
}

func (tsu *TestSummaryUpdate) sqlSave(ctx context.Context) (n int, err error) {
	if err := tsu.check(); err != nil {
		return n, err
	}
	_spec := sqlgraph.NewUpdateSpec(testsummary.Table, testsummary.Columns, sqlgraph.NewFieldSpec(testsummary.FieldID, field.TypeInt))
	if ps := tsu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tsu.mutation.OverallStatus(); ok {
		_spec.SetField(testsummary.FieldOverallStatus, field.TypeEnum, value)
	}
	if tsu.mutation.OverallStatusCleared() {
		_spec.ClearField(testsummary.FieldOverallStatus, field.TypeEnum)
	}
	if value, ok := tsu.mutation.TotalRunCount(); ok {
		_spec.SetField(testsummary.FieldTotalRunCount, field.TypeInt32, value)
	}
	if value, ok := tsu.mutation.AddedTotalRunCount(); ok {
		_spec.AddField(testsummary.FieldTotalRunCount, field.TypeInt32, value)
	}
	if tsu.mutation.TotalRunCountCleared() {
		_spec.ClearField(testsummary.FieldTotalRunCount, field.TypeInt32)
	}
	if value, ok := tsu.mutation.RunCount(); ok {
		_spec.SetField(testsummary.FieldRunCount, field.TypeInt32, value)
	}
	if value, ok := tsu.mutation.AddedRunCount(); ok {
		_spec.AddField(testsummary.FieldRunCount, field.TypeInt32, value)
	}
	if tsu.mutation.RunCountCleared() {
		_spec.ClearField(testsummary.FieldRunCount, field.TypeInt32)
	}
	if value, ok := tsu.mutation.AttemptCount(); ok {
		_spec.SetField(testsummary.FieldAttemptCount, field.TypeInt32, value)
	}
	if value, ok := tsu.mutation.AddedAttemptCount(); ok {
		_spec.AddField(testsummary.FieldAttemptCount, field.TypeInt32, value)
	}
	if tsu.mutation.AttemptCountCleared() {
		_spec.ClearField(testsummary.FieldAttemptCount, field.TypeInt32)
	}
	if value, ok := tsu.mutation.ShardCount(); ok {
		_spec.SetField(testsummary.FieldShardCount, field.TypeInt32, value)
	}
	if value, ok := tsu.mutation.AddedShardCount(); ok {
		_spec.AddField(testsummary.FieldShardCount, field.TypeInt32, value)
	}
	if tsu.mutation.ShardCountCleared() {
		_spec.ClearField(testsummary.FieldShardCount, field.TypeInt32)
	}
	if value, ok := tsu.mutation.TotalNumCached(); ok {
		_spec.SetField(testsummary.FieldTotalNumCached, field.TypeInt32, value)
	}
	if value, ok := tsu.mutation.AddedTotalNumCached(); ok {
		_spec.AddField(testsummary.FieldTotalNumCached, field.TypeInt32, value)
	}
	if tsu.mutation.TotalNumCachedCleared() {
		_spec.ClearField(testsummary.FieldTotalNumCached, field.TypeInt32)
	}
	if value, ok := tsu.mutation.FirstStartTime(); ok {
		_spec.SetField(testsummary.FieldFirstStartTime, field.TypeInt64, value)
	}
	if value, ok := tsu.mutation.AddedFirstStartTime(); ok {
		_spec.AddField(testsummary.FieldFirstStartTime, field.TypeInt64, value)
	}
	if tsu.mutation.FirstStartTimeCleared() {
		_spec.ClearField(testsummary.FieldFirstStartTime, field.TypeInt64)
	}
	if value, ok := tsu.mutation.LastStopTime(); ok {
		_spec.SetField(testsummary.FieldLastStopTime, field.TypeInt64, value)
	}
	if value, ok := tsu.mutation.AddedLastStopTime(); ok {
		_spec.AddField(testsummary.FieldLastStopTime, field.TypeInt64, value)
	}
	if tsu.mutation.LastStopTimeCleared() {
		_spec.ClearField(testsummary.FieldLastStopTime, field.TypeInt64)
	}
	if value, ok := tsu.mutation.TotalRunDuration(); ok {
		_spec.SetField(testsummary.FieldTotalRunDuration, field.TypeInt64, value)
	}
	if value, ok := tsu.mutation.AddedTotalRunDuration(); ok {
		_spec.AddField(testsummary.FieldTotalRunDuration, field.TypeInt64, value)
	}
	if tsu.mutation.TotalRunDurationCleared() {
		_spec.ClearField(testsummary.FieldTotalRunDuration, field.TypeInt64)
	}
	if value, ok := tsu.mutation.Label(); ok {
		_spec.SetField(testsummary.FieldLabel, field.TypeString, value)
	}
	if tsu.mutation.LabelCleared() {
		_spec.ClearField(testsummary.FieldLabel, field.TypeString)
	}
	if tsu.mutation.TestCollectionCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   testsummary.TestCollectionTable,
			Columns: []string{testsummary.TestCollectionColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testcollection.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsu.mutation.TestCollectionIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   testsummary.TestCollectionTable,
			Columns: []string{testsummary.TestCollectionColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testcollection.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tsu.mutation.PassedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsu.mutation.RemovedPassedIDs(); len(nodes) > 0 && !tsu.mutation.PassedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsu.mutation.PassedIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tsu.mutation.FailedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsu.mutation.RemovedFailedIDs(); len(nodes) > 0 && !tsu.mutation.FailedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsu.mutation.FailedIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if n, err = sqlgraph.UpdateNodes(ctx, tsu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{testsummary.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	tsu.mutation.done = true
	return n, nil
}

// TestSummaryUpdateOne is the builder for updating a single TestSummary entity.
type TestSummaryUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *TestSummaryMutation
}

// SetOverallStatus sets the "overall_status" field.
func (tsuo *TestSummaryUpdateOne) SetOverallStatus(ts testsummary.OverallStatus) *TestSummaryUpdateOne {
	tsuo.mutation.SetOverallStatus(ts)
	return tsuo
}

// SetNillableOverallStatus sets the "overall_status" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableOverallStatus(ts *testsummary.OverallStatus) *TestSummaryUpdateOne {
	if ts != nil {
		tsuo.SetOverallStatus(*ts)
	}
	return tsuo
}

// ClearOverallStatus clears the value of the "overall_status" field.
func (tsuo *TestSummaryUpdateOne) ClearOverallStatus() *TestSummaryUpdateOne {
	tsuo.mutation.ClearOverallStatus()
	return tsuo
}

// SetTotalRunCount sets the "total_run_count" field.
func (tsuo *TestSummaryUpdateOne) SetTotalRunCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.ResetTotalRunCount()
	tsuo.mutation.SetTotalRunCount(i)
	return tsuo
}

// SetNillableTotalRunCount sets the "total_run_count" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableTotalRunCount(i *int32) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetTotalRunCount(*i)
	}
	return tsuo
}

// AddTotalRunCount adds i to the "total_run_count" field.
func (tsuo *TestSummaryUpdateOne) AddTotalRunCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.AddTotalRunCount(i)
	return tsuo
}

// ClearTotalRunCount clears the value of the "total_run_count" field.
func (tsuo *TestSummaryUpdateOne) ClearTotalRunCount() *TestSummaryUpdateOne {
	tsuo.mutation.ClearTotalRunCount()
	return tsuo
}

// SetRunCount sets the "run_count" field.
func (tsuo *TestSummaryUpdateOne) SetRunCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.ResetRunCount()
	tsuo.mutation.SetRunCount(i)
	return tsuo
}

// SetNillableRunCount sets the "run_count" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableRunCount(i *int32) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetRunCount(*i)
	}
	return tsuo
}

// AddRunCount adds i to the "run_count" field.
func (tsuo *TestSummaryUpdateOne) AddRunCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.AddRunCount(i)
	return tsuo
}

// ClearRunCount clears the value of the "run_count" field.
func (tsuo *TestSummaryUpdateOne) ClearRunCount() *TestSummaryUpdateOne {
	tsuo.mutation.ClearRunCount()
	return tsuo
}

// SetAttemptCount sets the "attempt_count" field.
func (tsuo *TestSummaryUpdateOne) SetAttemptCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.ResetAttemptCount()
	tsuo.mutation.SetAttemptCount(i)
	return tsuo
}

// SetNillableAttemptCount sets the "attempt_count" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableAttemptCount(i *int32) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetAttemptCount(*i)
	}
	return tsuo
}

// AddAttemptCount adds i to the "attempt_count" field.
func (tsuo *TestSummaryUpdateOne) AddAttemptCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.AddAttemptCount(i)
	return tsuo
}

// ClearAttemptCount clears the value of the "attempt_count" field.
func (tsuo *TestSummaryUpdateOne) ClearAttemptCount() *TestSummaryUpdateOne {
	tsuo.mutation.ClearAttemptCount()
	return tsuo
}

// SetShardCount sets the "shard_count" field.
func (tsuo *TestSummaryUpdateOne) SetShardCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.ResetShardCount()
	tsuo.mutation.SetShardCount(i)
	return tsuo
}

// SetNillableShardCount sets the "shard_count" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableShardCount(i *int32) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetShardCount(*i)
	}
	return tsuo
}

// AddShardCount adds i to the "shard_count" field.
func (tsuo *TestSummaryUpdateOne) AddShardCount(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.AddShardCount(i)
	return tsuo
}

// ClearShardCount clears the value of the "shard_count" field.
func (tsuo *TestSummaryUpdateOne) ClearShardCount() *TestSummaryUpdateOne {
	tsuo.mutation.ClearShardCount()
	return tsuo
}

// SetTotalNumCached sets the "total_num_cached" field.
func (tsuo *TestSummaryUpdateOne) SetTotalNumCached(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.ResetTotalNumCached()
	tsuo.mutation.SetTotalNumCached(i)
	return tsuo
}

// SetNillableTotalNumCached sets the "total_num_cached" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableTotalNumCached(i *int32) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetTotalNumCached(*i)
	}
	return tsuo
}

// AddTotalNumCached adds i to the "total_num_cached" field.
func (tsuo *TestSummaryUpdateOne) AddTotalNumCached(i int32) *TestSummaryUpdateOne {
	tsuo.mutation.AddTotalNumCached(i)
	return tsuo
}

// ClearTotalNumCached clears the value of the "total_num_cached" field.
func (tsuo *TestSummaryUpdateOne) ClearTotalNumCached() *TestSummaryUpdateOne {
	tsuo.mutation.ClearTotalNumCached()
	return tsuo
}

// SetFirstStartTime sets the "first_start_time" field.
func (tsuo *TestSummaryUpdateOne) SetFirstStartTime(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.ResetFirstStartTime()
	tsuo.mutation.SetFirstStartTime(i)
	return tsuo
}

// SetNillableFirstStartTime sets the "first_start_time" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableFirstStartTime(i *int64) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetFirstStartTime(*i)
	}
	return tsuo
}

// AddFirstStartTime adds i to the "first_start_time" field.
func (tsuo *TestSummaryUpdateOne) AddFirstStartTime(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.AddFirstStartTime(i)
	return tsuo
}

// ClearFirstStartTime clears the value of the "first_start_time" field.
func (tsuo *TestSummaryUpdateOne) ClearFirstStartTime() *TestSummaryUpdateOne {
	tsuo.mutation.ClearFirstStartTime()
	return tsuo
}

// SetLastStopTime sets the "last_stop_time" field.
func (tsuo *TestSummaryUpdateOne) SetLastStopTime(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.ResetLastStopTime()
	tsuo.mutation.SetLastStopTime(i)
	return tsuo
}

// SetNillableLastStopTime sets the "last_stop_time" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableLastStopTime(i *int64) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetLastStopTime(*i)
	}
	return tsuo
}

// AddLastStopTime adds i to the "last_stop_time" field.
func (tsuo *TestSummaryUpdateOne) AddLastStopTime(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.AddLastStopTime(i)
	return tsuo
}

// ClearLastStopTime clears the value of the "last_stop_time" field.
func (tsuo *TestSummaryUpdateOne) ClearLastStopTime() *TestSummaryUpdateOne {
	tsuo.mutation.ClearLastStopTime()
	return tsuo
}

// SetTotalRunDuration sets the "total_run_duration" field.
func (tsuo *TestSummaryUpdateOne) SetTotalRunDuration(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.ResetTotalRunDuration()
	tsuo.mutation.SetTotalRunDuration(i)
	return tsuo
}

// SetNillableTotalRunDuration sets the "total_run_duration" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableTotalRunDuration(i *int64) *TestSummaryUpdateOne {
	if i != nil {
		tsuo.SetTotalRunDuration(*i)
	}
	return tsuo
}

// AddTotalRunDuration adds i to the "total_run_duration" field.
func (tsuo *TestSummaryUpdateOne) AddTotalRunDuration(i int64) *TestSummaryUpdateOne {
	tsuo.mutation.AddTotalRunDuration(i)
	return tsuo
}

// ClearTotalRunDuration clears the value of the "total_run_duration" field.
func (tsuo *TestSummaryUpdateOne) ClearTotalRunDuration() *TestSummaryUpdateOne {
	tsuo.mutation.ClearTotalRunDuration()
	return tsuo
}

// SetLabel sets the "label" field.
func (tsuo *TestSummaryUpdateOne) SetLabel(s string) *TestSummaryUpdateOne {
	tsuo.mutation.SetLabel(s)
	return tsuo
}

// SetNillableLabel sets the "label" field if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableLabel(s *string) *TestSummaryUpdateOne {
	if s != nil {
		tsuo.SetLabel(*s)
	}
	return tsuo
}

// ClearLabel clears the value of the "label" field.
func (tsuo *TestSummaryUpdateOne) ClearLabel() *TestSummaryUpdateOne {
	tsuo.mutation.ClearLabel()
	return tsuo
}

// SetTestCollectionID sets the "test_collection" edge to the TestCollection entity by ID.
func (tsuo *TestSummaryUpdateOne) SetTestCollectionID(id int) *TestSummaryUpdateOne {
	tsuo.mutation.SetTestCollectionID(id)
	return tsuo
}

// SetNillableTestCollectionID sets the "test_collection" edge to the TestCollection entity by ID if the given value is not nil.
func (tsuo *TestSummaryUpdateOne) SetNillableTestCollectionID(id *int) *TestSummaryUpdateOne {
	if id != nil {
		tsuo = tsuo.SetTestCollectionID(*id)
	}
	return tsuo
}

// SetTestCollection sets the "test_collection" edge to the TestCollection entity.
func (tsuo *TestSummaryUpdateOne) SetTestCollection(t *TestCollection) *TestSummaryUpdateOne {
	return tsuo.SetTestCollectionID(t.ID)
}

// AddPassedIDs adds the "passed" edge to the TestFile entity by IDs.
func (tsuo *TestSummaryUpdateOne) AddPassedIDs(ids ...int) *TestSummaryUpdateOne {
	tsuo.mutation.AddPassedIDs(ids...)
	return tsuo
}

// AddPassed adds the "passed" edges to the TestFile entity.
func (tsuo *TestSummaryUpdateOne) AddPassed(t ...*TestFile) *TestSummaryUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsuo.AddPassedIDs(ids...)
}

// AddFailedIDs adds the "failed" edge to the TestFile entity by IDs.
func (tsuo *TestSummaryUpdateOne) AddFailedIDs(ids ...int) *TestSummaryUpdateOne {
	tsuo.mutation.AddFailedIDs(ids...)
	return tsuo
}

// AddFailed adds the "failed" edges to the TestFile entity.
func (tsuo *TestSummaryUpdateOne) AddFailed(t ...*TestFile) *TestSummaryUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsuo.AddFailedIDs(ids...)
}

// Mutation returns the TestSummaryMutation object of the builder.
func (tsuo *TestSummaryUpdateOne) Mutation() *TestSummaryMutation {
	return tsuo.mutation
}

// ClearTestCollection clears the "test_collection" edge to the TestCollection entity.
func (tsuo *TestSummaryUpdateOne) ClearTestCollection() *TestSummaryUpdateOne {
	tsuo.mutation.ClearTestCollection()
	return tsuo
}

// ClearPassed clears all "passed" edges to the TestFile entity.
func (tsuo *TestSummaryUpdateOne) ClearPassed() *TestSummaryUpdateOne {
	tsuo.mutation.ClearPassed()
	return tsuo
}

// RemovePassedIDs removes the "passed" edge to TestFile entities by IDs.
func (tsuo *TestSummaryUpdateOne) RemovePassedIDs(ids ...int) *TestSummaryUpdateOne {
	tsuo.mutation.RemovePassedIDs(ids...)
	return tsuo
}

// RemovePassed removes "passed" edges to TestFile entities.
func (tsuo *TestSummaryUpdateOne) RemovePassed(t ...*TestFile) *TestSummaryUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsuo.RemovePassedIDs(ids...)
}

// ClearFailed clears all "failed" edges to the TestFile entity.
func (tsuo *TestSummaryUpdateOne) ClearFailed() *TestSummaryUpdateOne {
	tsuo.mutation.ClearFailed()
	return tsuo
}

// RemoveFailedIDs removes the "failed" edge to TestFile entities by IDs.
func (tsuo *TestSummaryUpdateOne) RemoveFailedIDs(ids ...int) *TestSummaryUpdateOne {
	tsuo.mutation.RemoveFailedIDs(ids...)
	return tsuo
}

// RemoveFailed removes "failed" edges to TestFile entities.
func (tsuo *TestSummaryUpdateOne) RemoveFailed(t ...*TestFile) *TestSummaryUpdateOne {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tsuo.RemoveFailedIDs(ids...)
}

// Where appends a list predicates to the TestSummaryUpdate builder.
func (tsuo *TestSummaryUpdateOne) Where(ps ...predicate.TestSummary) *TestSummaryUpdateOne {
	tsuo.mutation.Where(ps...)
	return tsuo
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (tsuo *TestSummaryUpdateOne) Select(field string, fields ...string) *TestSummaryUpdateOne {
	tsuo.fields = append([]string{field}, fields...)
	return tsuo
}

// Save executes the query and returns the updated TestSummary entity.
func (tsuo *TestSummaryUpdateOne) Save(ctx context.Context) (*TestSummary, error) {
	return withHooks(ctx, tsuo.sqlSave, tsuo.mutation, tsuo.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (tsuo *TestSummaryUpdateOne) SaveX(ctx context.Context) *TestSummary {
	node, err := tsuo.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (tsuo *TestSummaryUpdateOne) Exec(ctx context.Context) error {
	_, err := tsuo.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (tsuo *TestSummaryUpdateOne) ExecX(ctx context.Context) {
	if err := tsuo.Exec(ctx); err != nil {
		panic(err)
	}
}

// check runs all checks and user-defined validators on the builder.
func (tsuo *TestSummaryUpdateOne) check() error {
	if v, ok := tsuo.mutation.OverallStatus(); ok {
		if err := testsummary.OverallStatusValidator(v); err != nil {
			return &ValidationError{Name: "overall_status", err: fmt.Errorf(`ent: validator failed for field "TestSummary.overall_status": %w`, err)}
		}
	}
	return nil
}

func (tsuo *TestSummaryUpdateOne) sqlSave(ctx context.Context) (_node *TestSummary, err error) {
	if err := tsuo.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(testsummary.Table, testsummary.Columns, sqlgraph.NewFieldSpec(testsummary.FieldID, field.TypeInt))
	id, ok := tsuo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TestSummary.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := tsuo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, testsummary.FieldID)
		for _, f := range fields {
			if !testsummary.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != testsummary.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := tsuo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := tsuo.mutation.OverallStatus(); ok {
		_spec.SetField(testsummary.FieldOverallStatus, field.TypeEnum, value)
	}
	if tsuo.mutation.OverallStatusCleared() {
		_spec.ClearField(testsummary.FieldOverallStatus, field.TypeEnum)
	}
	if value, ok := tsuo.mutation.TotalRunCount(); ok {
		_spec.SetField(testsummary.FieldTotalRunCount, field.TypeInt32, value)
	}
	if value, ok := tsuo.mutation.AddedTotalRunCount(); ok {
		_spec.AddField(testsummary.FieldTotalRunCount, field.TypeInt32, value)
	}
	if tsuo.mutation.TotalRunCountCleared() {
		_spec.ClearField(testsummary.FieldTotalRunCount, field.TypeInt32)
	}
	if value, ok := tsuo.mutation.RunCount(); ok {
		_spec.SetField(testsummary.FieldRunCount, field.TypeInt32, value)
	}
	if value, ok := tsuo.mutation.AddedRunCount(); ok {
		_spec.AddField(testsummary.FieldRunCount, field.TypeInt32, value)
	}
	if tsuo.mutation.RunCountCleared() {
		_spec.ClearField(testsummary.FieldRunCount, field.TypeInt32)
	}
	if value, ok := tsuo.mutation.AttemptCount(); ok {
		_spec.SetField(testsummary.FieldAttemptCount, field.TypeInt32, value)
	}
	if value, ok := tsuo.mutation.AddedAttemptCount(); ok {
		_spec.AddField(testsummary.FieldAttemptCount, field.TypeInt32, value)
	}
	if tsuo.mutation.AttemptCountCleared() {
		_spec.ClearField(testsummary.FieldAttemptCount, field.TypeInt32)
	}
	if value, ok := tsuo.mutation.ShardCount(); ok {
		_spec.SetField(testsummary.FieldShardCount, field.TypeInt32, value)
	}
	if value, ok := tsuo.mutation.AddedShardCount(); ok {
		_spec.AddField(testsummary.FieldShardCount, field.TypeInt32, value)
	}
	if tsuo.mutation.ShardCountCleared() {
		_spec.ClearField(testsummary.FieldShardCount, field.TypeInt32)
	}
	if value, ok := tsuo.mutation.TotalNumCached(); ok {
		_spec.SetField(testsummary.FieldTotalNumCached, field.TypeInt32, value)
	}
	if value, ok := tsuo.mutation.AddedTotalNumCached(); ok {
		_spec.AddField(testsummary.FieldTotalNumCached, field.TypeInt32, value)
	}
	if tsuo.mutation.TotalNumCachedCleared() {
		_spec.ClearField(testsummary.FieldTotalNumCached, field.TypeInt32)
	}
	if value, ok := tsuo.mutation.FirstStartTime(); ok {
		_spec.SetField(testsummary.FieldFirstStartTime, field.TypeInt64, value)
	}
	if value, ok := tsuo.mutation.AddedFirstStartTime(); ok {
		_spec.AddField(testsummary.FieldFirstStartTime, field.TypeInt64, value)
	}
	if tsuo.mutation.FirstStartTimeCleared() {
		_spec.ClearField(testsummary.FieldFirstStartTime, field.TypeInt64)
	}
	if value, ok := tsuo.mutation.LastStopTime(); ok {
		_spec.SetField(testsummary.FieldLastStopTime, field.TypeInt64, value)
	}
	if value, ok := tsuo.mutation.AddedLastStopTime(); ok {
		_spec.AddField(testsummary.FieldLastStopTime, field.TypeInt64, value)
	}
	if tsuo.mutation.LastStopTimeCleared() {
		_spec.ClearField(testsummary.FieldLastStopTime, field.TypeInt64)
	}
	if value, ok := tsuo.mutation.TotalRunDuration(); ok {
		_spec.SetField(testsummary.FieldTotalRunDuration, field.TypeInt64, value)
	}
	if value, ok := tsuo.mutation.AddedTotalRunDuration(); ok {
		_spec.AddField(testsummary.FieldTotalRunDuration, field.TypeInt64, value)
	}
	if tsuo.mutation.TotalRunDurationCleared() {
		_spec.ClearField(testsummary.FieldTotalRunDuration, field.TypeInt64)
	}
	if value, ok := tsuo.mutation.Label(); ok {
		_spec.SetField(testsummary.FieldLabel, field.TypeString, value)
	}
	if tsuo.mutation.LabelCleared() {
		_spec.ClearField(testsummary.FieldLabel, field.TypeString)
	}
	if tsuo.mutation.TestCollectionCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   testsummary.TestCollectionTable,
			Columns: []string{testsummary.TestCollectionColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testcollection.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsuo.mutation.TestCollectionIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2O,
			Inverse: true,
			Table:   testsummary.TestCollectionTable,
			Columns: []string{testsummary.TestCollectionColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testcollection.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tsuo.mutation.PassedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsuo.mutation.RemovedPassedIDs(); len(nodes) > 0 && !tsuo.mutation.PassedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsuo.mutation.PassedIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.PassedTable,
			Columns: []string{testsummary.PassedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if tsuo.mutation.FailedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsuo.mutation.RemovedFailedIDs(); len(nodes) > 0 && !tsuo.mutation.FailedCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := tsuo.mutation.FailedIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   testsummary.FailedTable,
			Columns: []string{testsummary.FailedColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(testfile.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &TestSummary{config: tsuo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, tsuo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{testsummary.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	tsuo.mutation.done = true
	return _node, nil
}
