Documentation
¶
Index ¶
- func AssertFileEquals(t *testing.T, expectedFilePath, actualFilePath string)
- func AssertFileEqualsString(t *testing.T, expectedFilePath, actual string)
- func AssertValidationError(t *testing.T, responseRecorder *httptest.ResponseRecorder, ...)
- func AssertValidationErrors(t *testing.T, responseRecorder *httptest.ResponseRecorder, ...)
- func BoolPtr(b bool) *bool
- func CreateDeleteRequest(url string) *http.Request
- func CreateGetRequest(t *testing.T, url string) *http.Request
- func CreatePatchRequest(t *testing.T, url string, payload interface{}) *http.Request
- func CreatePostRequest(t *testing.T, url string, payload interface{}) *http.Request
- func CreatePutRequest(t *testing.T, url string, payload interface{}) *http.Request
- func DumpTable(t *testing.T, db *dbutils.DBPool, tableName string)
- func GetProjectRoot() string
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func NewRouter() *chi.Mux
- func SetupTestDB(t *testing.T) *sql.DB
- func StringPtr(s string) *string
- type MockFileService
- type Option
- type TestApp
- func (a *TestApp) MakeAuthenticatedDeleteRequest(t *testing.T, path string) *httptest.ResponseRecorder
- func (a *TestApp) MakeAuthenticatedGetRequest(t *testing.T, path string) *httptest.ResponseRecorder
- func (a *TestApp) MakeAuthenticatedPatchRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
- func (a *TestApp) MakeAuthenticatedPostRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
- func (a *TestApp) MakeAuthenticatedPutRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
- func (a *TestApp) MakeRequest(req *http.Request) *httptest.ResponseRecorder
- type ValidationErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileEquals ¶
func AssertFileEqualsString ¶
func AssertValidationError ¶
func AssertValidationErrors ¶
func AssertValidationErrors(t *testing.T, responseRecorder *httptest.ResponseRecorder, expectedErrors validation.ValidationError)
func CreateDeleteRequest ¶
func CreatePatchRequest ¶
func CreatePostRequest ¶
func CreatePutRequest ¶
func GetProjectRoot ¶
func GetProjectRoot() string
Types ¶
type MockFileService ¶
type MockFileService struct {
UploadedFileName string
DownloadedFileName string
DeletedFileNames []string
DownloadedFile []byte
UploadedFile io.Reader
UploadedLocation string
}
func NewMockFileService ¶
func NewMockFileService() *MockFileService
func (*MockFileService) DeleteFile ¶
func (s *MockFileService) DeleteFile(fileName string) error
func (*MockFileService) DeleteFiles ¶
func (s *MockFileService) DeleteFiles(fileNames []string) error
func (*MockFileService) DownloadFile ¶
func (s *MockFileService) DownloadFile(fileName string) ([]byte, error)
func (*MockFileService) UploadFile ¶
type TestApp ¶
func (*TestApp) MakeAuthenticatedDeleteRequest ¶
func (a *TestApp) MakeAuthenticatedDeleteRequest(t *testing.T, path string) *httptest.ResponseRecorder
MakeAuthenticatedDeleteRequest issues a DELETE request to the given path with a default test user as the authenticated user. The caller is responsible for ensuring that the test user exists in the database.
func (*TestApp) MakeAuthenticatedGetRequest ¶
MakeAuthenticatedGetRequest issues a GET request to the given path with a default test user as the authenticated user. The caller is responsible for ensuring that the test user exists in the database.
func (*TestApp) MakeAuthenticatedPatchRequest ¶
func (a *TestApp) MakeAuthenticatedPatchRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
MakeAuthenticatedPatchRequest issues a PATCH request to the given path with a default test user as the authenticated user. The caller is responsible for ensuring that the test user exists in the database.
func (*TestApp) MakeAuthenticatedPostRequest ¶
func (a *TestApp) MakeAuthenticatedPostRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
MakeAuthenticatedPostRequest issues a POST request to the given path with a default test user as the authenticated user. The caller is responsible for ensuring that the test user exists in the database.
func (*TestApp) MakeAuthenticatedPutRequest ¶
func (a *TestApp) MakeAuthenticatedPutRequest(t *testing.T, path string, body interface{}) *httptest.ResponseRecorder
MakeAuthenticatedPutRequest issues a PUT request to the given path with a default test user as the authenticated user. The caller is responsible for ensuring that the test user exists in the database.
func (*TestApp) MakeRequest ¶
func (a *TestApp) MakeRequest(req *http.Request) *httptest.ResponseRecorder
type ValidationErrorResponse ¶
type ValidationErrorResponse struct {
Errors []validation.Error `json:"errors"`
}