Example #1
0
func newInternship(t *testing.T, student schema.Student, tutor schema.User) schema.Internship {
	creation := time.Now()
	c := schema.Convention{
		Student:    student,
		Tutor:      tutor,
		Supervisor: testutil.Person(),
		Creation:   creation,
		Begin:      creation.Add(time.Minute),
		End:        creation.Add(time.Hour),
		Company: schema.Company{
			Title: string(randomBytes(10)),
			WWW:   string(randomBytes(10)),
			Name:  string(randomBytes(10)),
		},
		//tons of default values
		Gratification:  10000,
		Lab:            false,
		ForeignCountry: true,
		Skip:           false,
		Valid:          false,
	}
	i, _, err := store.NewInternship(c)
	assert.Nil(t, err)
	c.Creation = c.Creation.Truncate(time.Minute).UTC()
	c.Begin = c.Begin.Truncate(time.Minute).UTC()
	c.End = c.End.Truncate(time.Minute).UTC()
	i.Convention = c
	return i
}
Example #2
0
func scanConvention(rows *sql.Rows) (schema.Convention, error) {
	var nextContact sql.NullString
	var nextPosition sql.NullString
	var nextFrance, nextPermanent, nextSameCompany sql.NullBool
	var role string
	c := schema.Convention{
		Student: schema.Student{
			User: schema.User{
				Person: schema.Person{},
				Role:   schema.STUDENT,
			},
			Alumni: &schema.Alumni{},
		},
		Tutor: schema.User{
			Person: schema.Person{},
		},
		Supervisor: schema.Person{},
		Company:    schema.Company{},
	}
	err := rows.Scan(
		&c.Student.User.Person.Firstname,
		&c.Student.User.Person.Lastname,
		&c.Student.User.Person.Tel,
		&c.Student.User.Person.Email,
		&c.Student.User.LastVisit,
		&c.Student.Male,
		&c.Student.Promotion,
		&c.Student.Major,
		&nextPosition,
		&nextFrance,
		&nextPermanent,
		&nextSameCompany,
		&nextContact,
		&c.Student.Skip,
		&c.Tutor.Person.Firstname,
		&c.Tutor.Person.Lastname,
		&c.Tutor.Person.Tel,
		&c.Tutor.Person.Email,
		&c.Tutor.LastVisit,
		&role,
		&c.Begin,
		&c.End,
		&c.Company.Name,
		&c.Company.WWW,
		&c.Company.Title,
		&c.Creation,
		&c.ForeignCountry,
		&c.Lab,
		&c.Gratification,
		&c.Supervisor.Firstname,
		&c.Supervisor.Lastname,
		&c.Supervisor.Email,
		&c.Supervisor.Tel,
	)
	c.Begin = c.Begin.UTC()
	c.End = c.End.UTC()
	c.Creation = c.Creation.UTC()

	c.Tutor.Role = schema.Role(role)
	if !nextPosition.Valid {
		c.Student.Alumni = nil
	} else {
		c.Student.Alumni.Position = nullableString(nextPosition)
		c.Student.Alumni.France = nullableBool(nextFrance, false)
		c.Student.Alumni.Permanent = nullableBool(nextPermanent, false)
		c.Student.Alumni.SameCompany = nullableBool(nextSameCompany, false)
		c.Student.Alumni.Contact = nullableString(nextContact)
	}
	return c, err
}