qtest

package
v0.0.0-...-ed8ca81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MockOrg = "qf102-2022"

Variables

View Source
var MockCourses = []*qf.Course{
	{
		Name:                "Distributed Systems",
		CourseCreatorID:     1,
		Code:                "DAT520",
		Year:                2018,
		Tag:                 "Spring",
		ScmOrganizationID:   1,
		ScmOrganizationName: MockOrg,
	},
	{
		Name:                "Operating Systems",
		CourseCreatorID:     1,
		Code:                "DAT320",
		Year:                2017,
		Tag:                 "Fall",
		ScmOrganizationID:   2,
		ScmOrganizationName: "DAT320",
	},
	{
		Name:                "New Systems",
		CourseCreatorID:     1,
		Code:                "DATx20",
		Year:                2019,
		Tag:                 "Fall",
		ScmOrganizationID:   3,
		ScmOrganizationName: "DATx20-2019",
	},
	{
		Name:                "Hyped Systems",
		CourseCreatorID:     1,
		Code:                "QF104",
		Year:                2022,
		Tag:                 "Fall",
		ScmOrganizationID:   4,
		ScmOrganizationName: "qf104-2022",
	},
}

Functions

func CreateCourse

func CreateCourse(t *testing.T, db database.Database, user *qf.User, course *qf.Course)

func CreateFakeCustomUser

func CreateFakeCustomUser(t *testing.T, db database.Database, user *qf.User) *qf.User

func CreateFakeUser

func CreateFakeUser(t *testing.T, db database.Database) *qf.User

CreateFakeUser is a test helper to create a user in the database.

func EnrollStudent

func EnrollStudent(t *testing.T, db database.Database, student *qf.User, course *qf.Course)

func EnrollTeacher

func EnrollTeacher(t *testing.T, db database.Database, student *qf.User, course *qf.Course)

func EnrollUser

func EnrollUser(t *testing.T, db database.Database, user *qf.User, course *qf.Course, status qf.Enrollment_UserStatus) *qf.Enrollment

func Logger

func Logger(t *testing.T) *zap.SugaredLogger

func RandomString

func RandomString(t *testing.T) string

func RequestWithCookie

func RequestWithCookie[T any](message *T, cookie string) *connect.Request[T]

func TestDB

func TestDB(t *testing.T) (database.Database, func())

TestDB returns a test database and close function. This function should only be used as a test helper.

func Timestamp

func Timestamp(t *testing.T, tim string) *timestamppb.Timestamp

Timestamp returns a protobuf timestamp representation of the given string time.

Types

type MockStream

type MockStream[T any] struct {
	Messages   []*T
	MessageMap map[string]int
	// contains filtered or unexported fields
}

func NewMockStream

func NewMockStream[T any](t *testing.T) *MockStream[T]

func (*MockStream[T]) Close

func (m *MockStream[T]) Close()

func (*MockStream[T]) GetChannel

func (m *MockStream[T]) GetChannel() chan *T

func (*MockStream[T]) Run

func (m *MockStream[T]) Run() error

func (*MockStream[T]) Send

func (m *MockStream[T]) Send(data *T)

func (*MockStream[T]) SetCounter

func (m *MockStream[T]) SetCounter(counter *uint32)

SetCounter sets the counter used to count the number of messages sent. Multiple streams can share the same counter to count the total number of messages sent across all streams.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL