// Code generated by ent, DO NOT EDIT.

package testresultbes

import (
	"fmt"
	"io"
	"strconv"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the testresultbes type in the database.
	Label = "test_result_bes"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldTestStatus holds the string denoting the test_status field in the database.
	FieldTestStatus = "test_status"
	// FieldStatusDetails holds the string denoting the status_details field in the database.
	FieldStatusDetails = "status_details"
	// FieldLabel holds the string denoting the label field in the database.
	FieldLabel = "label"
	// FieldWarning holds the string denoting the warning field in the database.
	FieldWarning = "warning"
	// FieldCachedLocally holds the string denoting the cached_locally field in the database.
	FieldCachedLocally = "cached_locally"
	// FieldTestAttemptStartMillisEpoch holds the string denoting the test_attempt_start_millis_epoch field in the database.
	FieldTestAttemptStartMillisEpoch = "test_attempt_start_millis_epoch"
	// FieldTestAttemptStart holds the string denoting the test_attempt_start field in the database.
	FieldTestAttemptStart = "test_attempt_start"
	// FieldTestAttemptDurationMillis holds the string denoting the test_attempt_duration_millis field in the database.
	FieldTestAttemptDurationMillis = "test_attempt_duration_millis"
	// FieldTestAttemptDuration holds the string denoting the test_attempt_duration field in the database.
	FieldTestAttemptDuration = "test_attempt_duration"
	// EdgeTestCollection holds the string denoting the test_collection edge name in mutations.
	EdgeTestCollection = "test_collection"
	// EdgeTestActionOutput holds the string denoting the test_action_output edge name in mutations.
	EdgeTestActionOutput = "test_action_output"
	// EdgeExecutionInfo holds the string denoting the execution_info edge name in mutations.
	EdgeExecutionInfo = "execution_info"
	// Table holds the table name of the testresultbes in the database.
	Table = "test_result_be_ss"
	// TestCollectionTable is the table that holds the test_collection relation/edge.
	TestCollectionTable = "test_result_be_ss"
	// TestCollectionInverseTable is the table name for the TestCollection entity.
	// It exists in this package in order to avoid circular dependency with the "testcollection" package.
	TestCollectionInverseTable = "test_collections"
	// TestCollectionColumn is the table column denoting the test_collection relation/edge.
	TestCollectionColumn = "test_collection_test_results"
	// TestActionOutputTable is the table that holds the test_action_output relation/edge.
	TestActionOutputTable = "test_files"
	// TestActionOutputInverseTable is the table name for the TestFile entity.
	// It exists in this package in order to avoid circular dependency with the "testfile" package.
	TestActionOutputInverseTable = "test_files"
	// TestActionOutputColumn is the table column denoting the test_action_output relation/edge.
	TestActionOutputColumn = "test_result_bes_test_action_output"
	// ExecutionInfoTable is the table that holds the execution_info relation/edge.
	ExecutionInfoTable = "exection_infos"
	// ExecutionInfoInverseTable is the table name for the ExectionInfo entity.
	// It exists in this package in order to avoid circular dependency with the "exectioninfo" package.
	ExecutionInfoInverseTable = "exection_infos"
	// ExecutionInfoColumn is the table column denoting the execution_info relation/edge.
	ExecutionInfoColumn = "test_result_bes_execution_info"
)

// Columns holds all SQL columns for testresultbes fields.
var Columns = []string{
	FieldID,
	FieldTestStatus,
	FieldStatusDetails,
	FieldLabel,
	FieldWarning,
	FieldCachedLocally,
	FieldTestAttemptStartMillisEpoch,
	FieldTestAttemptStart,
	FieldTestAttemptDurationMillis,
	FieldTestAttemptDuration,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "test_result_be_ss"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"test_collection_test_results",
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

// TestStatus defines the type for the "test_status" enum field.
type TestStatus string

// TestStatusNO_STATUS is the default value of the TestStatus enum.
const DefaultTestStatus = TestStatusNO_STATUS

// TestStatus values.
const (
	TestStatusNO_STATUS                  TestStatus = "NO_STATUS"
	TestStatusPASSED                     TestStatus = "PASSED"
	TestStatusFLAKY                      TestStatus = "FLAKY"
	TestStatusTIMEOUT                    TestStatus = "TIMEOUT"
	TestStatusFAILED                     TestStatus = "FAILED"
	TestStatusINCOMPLETE                 TestStatus = "INCOMPLETE"
	TestStatusREMOTE_FAILURE             TestStatus = "REMOTE_FAILURE"
	TestStatusFAILED_TO_BUILD            TestStatus = "FAILED_TO_BUILD"
	TestStatusTOOL_HALTED_BEFORE_TESTING TestStatus = "TOOL_HALTED_BEFORE_TESTING"
)

func (ts TestStatus) String() string {
	return string(ts)
}

// TestStatusValidator is a validator for the "test_status" field enum values. It is called by the builders before save.
func TestStatusValidator(ts TestStatus) error {
	switch ts {
	case TestStatusNO_STATUS, TestStatusPASSED, TestStatusFLAKY, TestStatusTIMEOUT, TestStatusFAILED, TestStatusINCOMPLETE, TestStatusREMOTE_FAILURE, TestStatusFAILED_TO_BUILD, TestStatusTOOL_HALTED_BEFORE_TESTING:
		return nil
	default:
		return fmt.Errorf("testresultbes: invalid enum value for test_status field: %q", ts)
	}
}

// OrderOption defines the ordering options for the TestResultBES queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByTestStatus orders the results by the test_status field.
func ByTestStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestStatus, opts...).ToFunc()
}

// ByStatusDetails orders the results by the status_details field.
func ByStatusDetails(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatusDetails, opts...).ToFunc()
}

// ByLabel orders the results by the label field.
func ByLabel(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLabel, opts...).ToFunc()
}

// ByCachedLocally orders the results by the cached_locally field.
func ByCachedLocally(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCachedLocally, opts...).ToFunc()
}

// ByTestAttemptStartMillisEpoch orders the results by the test_attempt_start_millis_epoch field.
func ByTestAttemptStartMillisEpoch(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestAttemptStartMillisEpoch, opts...).ToFunc()
}

// ByTestAttemptStart orders the results by the test_attempt_start field.
func ByTestAttemptStart(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestAttemptStart, opts...).ToFunc()
}

// ByTestAttemptDurationMillis orders the results by the test_attempt_duration_millis field.
func ByTestAttemptDurationMillis(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestAttemptDurationMillis, opts...).ToFunc()
}

// ByTestAttemptDuration orders the results by the test_attempt_duration field.
func ByTestAttemptDuration(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestAttemptDuration, opts...).ToFunc()
}

// ByTestCollectionField orders the results by test_collection field.
func ByTestCollectionField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTestCollectionStep(), sql.OrderByField(field, opts...))
	}
}

// ByTestActionOutputCount orders the results by test_action_output count.
func ByTestActionOutputCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newTestActionOutputStep(), opts...)
	}
}

// ByTestActionOutput orders the results by test_action_output terms.
func ByTestActionOutput(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTestActionOutputStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByExecutionInfoField orders the results by execution_info field.
func ByExecutionInfoField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newExecutionInfoStep(), sql.OrderByField(field, opts...))
	}
}
func newTestCollectionStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TestCollectionInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, TestCollectionTable, TestCollectionColumn),
	)
}
func newTestActionOutputStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TestActionOutputInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, TestActionOutputTable, TestActionOutputColumn),
	)
}
func newExecutionInfoStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(ExecutionInfoInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, false, ExecutionInfoTable, ExecutionInfoColumn),
	)
}

// MarshalGQL implements graphql.Marshaler interface.
func (e TestStatus) MarshalGQL(w io.Writer) {
	io.WriteString(w, strconv.Quote(e.String()))
}

// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *TestStatus) UnmarshalGQL(val interface{}) error {
	str, ok := val.(string)
	if !ok {
		return fmt.Errorf("enum %T must be a string", val)
	}
	*e = TestStatus(str)
	if err := TestStatusValidator(*e); err != nil {
		return fmt.Errorf("%s is not a valid TestStatus", str)
	}
	return nil
}
