mock

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidUser = "fakeUsername"
	ValidPass = "fakePassword"

	InvalidUser = "this-user-does-not-exist"
	InvalidPass = "this-password-does-not-either"

	AuthCookie        = "fakeAuthCookie"
	VerificationToken = "fakeRequestVerificationToken"
	SessionID         = "fakeSessionId"

	// StudentUUID is the UUID associated with the student used across testdata in filesystem.
	StudentUUID = "98RFGK88-A01C-1JJO-N73D-4BJR42B33J51"

	StudentName             = "John Doe"
	StudentEnrollmentNumber = "A2305221007"
	StudentIDCardNumber     = "95188911"
	StudentBloodGroup       = "B-ve"
	StudentProgram          = "B.Tech (CSE)"
	StudentBatch            = "2020-2024"

	StudentIDValidity Timestamp = 1719705600
	StudentDOB        Timestamp = 986428800

	// A valid mac address, and the first mac in the mock wifi pages
	ValidMac1   = "55-04-2d-e7-be-a4"
	ValidMac2   = "fd-d5-14-18-0c-8b"
	ValidMacNew = "dd-d5-14-18-0c-8c"
)

Constants for use in tests using the mock package to create Gock requests, etc.

View Source
const BaseUrl = "https://s.amizone.net"

Variables

This section is empty.

Functions

func GockRegisterAuthenticatedGet

func GockRegisterAuthenticatedGet(endpoint string, file File) error

GockRegisterAuthenticatedGet registers an authenticated GET request for the relative endpoint passed. The second parameter is used as the response body of the request.

func GockRegisterAuthenticatedGetWithParams added in v0.3.0

func GockRegisterAuthenticatedGetWithParams(endpoint string, params map[string]string, file File) error

GockRegisterAuthenticatedGetWithParams registers an authenticated GET request for the relative endpoint passed. The second parameter is used as the parameters of the request. The third parameter is used as the response body of the request.

func GockRegisterAuthenticatedPost

func GockRegisterAuthenticatedPost(endpoint string, requestMatcher gock.MatchFunc, file File) error

func GockRegisterCalendarEndpoint added in v0.4.0

func GockRegisterCalendarEndpoint(start, end string, file File) error

func GockRegisterCurrentCoursesPage

func GockRegisterCurrentCoursesPage() error

func GockRegisterExamResultPage added in v0.8.0

func GockRegisterExamResultPage() error

func GockRegisterExamResultRequest added in v0.8.0

func GockRegisterExamResultRequest(semesterRef string) error

func GockRegisterHomePageLoggedIn

func GockRegisterHomePageLoggedIn() error

GockRegisterHomePageLoggedIn registers a gock route for the amizone home page, serving the home page for a logged-in user from the mock filesystem. The request must have the referrers and cookies expected by the home page.

func GockRegisterLoginPage

func GockRegisterLoginPage() error

GockRegisterLoginPage registers a gock route for the amizone login page serving the login page from the mock filesystem.

func GockRegisterLoginRequest

func GockRegisterLoginRequest() error

GockRegisterLoginRequest registers 2 gock routes - one for valid credentials and one for invalid credentials. Valid credentials: ValidUser, ValidPass Invalid credentials: InvalidUser, InvalidPass

func GockRegisterProfilePage added in v0.2.0

func GockRegisterProfilePage() error

func GockRegisterSemWiseCoursesPage

func GockRegisterSemWiseCoursesPage() error

func GockRegisterSemesterCoursesRequest

func GockRegisterSemesterCoursesRequest(semesterRef string) error

func GockRegisterUnauthenticatedGet

func GockRegisterUnauthenticatedGet(endpoint string) error

GockRegisterUnauthenticatedGet registers an unauthenticated GET request for the relative endpoint passed.

func GockRegisterUnauthenticatedPost

func GockRegisterUnauthenticatedPost(endpoint string, requestBody string, responseBody io.Reader)

func GockRegisterWifiInfo added in v0.3.0

func GockRegisterWifiInfo() error

func GockRegisterWifiInfoOneSlot added in v0.3.0

func GockRegisterWifiInfoOneSlot() error

func GockRegisterWifiMacDeletion added in v0.3.0

func GockRegisterWifiMacDeletion(params map[string]string, response File) error

func GockRegisterWifiRegistration added in v0.3.0

func GockRegisterWifiRegistration(payload url.Values) error

GockRegisterWifiRegistration() registers a gock route for the wifi registration page. The request must have the expected referrer, cookies and post data to be successful.

Types

type ExpectedJSON added in v0.6.0

type ExpectedJSON string
const (
	ExpectedFacultyFeedbackSpec  ExpectedJSON = "testdata/expected__faculty_feedback_spec.json"
	ExpectedExamScheduleWithRoom ExpectedJSON = "testdata/expected__exam_schedule_with_room.json"
)

func (ExpectedJSON) Open added in v0.6.0

func (f ExpectedJSON) Open() (fs.File, error)

Open returns a fs.File interface to the file in filesystem, the mock filesystem.

type File

type File string
const (
	DiaryEventsNone                 File = "testdata/diary_events_none.json"
	DiaryEventsJSON                 File = "testdata/diary_events.json"
	DiaryEventsSmallJSON            File = "testdata/diary_events_small.json"
	ExaminationSchedule             File = "testdata/examination_schedule.html"
	ExaminationScheduleWithLocation File = "testdata/examination_schedule_exam_room.html"
	HomePageLoggedIn                File = "testdata/home_page_logged_in.html"
	LoginPage                       File = "testdata/login_page.html"
	CoursesPage                     File = "testdata/my_courses.html"
	CoursesPageSemWise              File = "testdata/courses_semwise.html"
	IDCardPage                      File = "testdata/id_card_page.html"
	WifiPage                        File = "testdata/wifi_mac_registration.html"
	WifiPageOneSlotPopulated        File = "testdata/wifi_mac_registration_one_empty.html"
	FacultyPage                     File = "testdata/faculty_page.html"
	ExaminationResultPage           File = "testdata/examination_result.html"
)

Constants for file paths in the filesystem embedded filesystem.

func (File) Open

func (f File) Open() (fs.File, error)

Open returns a fs.File interface to the file in filesystem, the mock filesystem.

type Timestamp added in v0.2.0

type Timestamp int64

func (Timestamp) Time added in v0.2.0

func (t Timestamp) Time() time.Time

Jump to

Keyboard shortcuts

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