You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we do not have a test for DeleteWorkspaceRepository
Design
We want to write the tests to use a real Postgres DB spun up on docker, follow the instructions in the Unit Testing section of README.md to run spin up a database in docker, and change the test_config.go configuration.
After spinning up the Postgres DB container:
Add this line of code on the first line and second of the test function TestDeleteWorkspaceRepository to connect to the Test DB
Get the created repository using db.TestDb.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid, repository_uuid) function
Assert that the repository was created
Create a test route using r.Delete("/{workspace_uuid}/repository/{uuid}", workspaceHandlers.DeleteWorkspaceRepository) as a reference, the test route
workspace.Uuid, and repository.Uuid should be used as URL parameters for the route
Assertions
Assert that it throws a 401 error if a user is not authorized
Assert that the repository is deleted after the Delete API request is successful by using the db.TestDb.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid, repository_uuid), the function should return an empty object.
Assert that all the test passes
Acceptance Criteria
I have rebased and tested locally before submitting my PR
I can submit a PR within 1 day of taking the bounty
Context
Currently, we do not have a test for DeleteWorkspaceRepository
Design
We want to write the tests to use a real Postgres DB spun up on docker, follow the instructions in the
Unit Testing
section of README.md to run spin up a database in docker, and change thetest_config.go
configuration.After spinning up the Postgres DB container:
TestDeleteWorkspaceRepository
to connect to the Test DBteardownSuite := SetupSuite(t) defer teardownSuite(t) oHandler := NewWorkspaceHandler(mockDb)` to `oHandler := NewWorkspaceHandler(db.TestDb)
The test will throw a dereference error if not connected to a DB.
db.TestDb.CreateOrPerson()
function e.gdb.TestDb.CreateOrEditWorkspace()
function e.gworkspace:= db.TestDb.GetWorkspaceByUuid(workspace.Uuid)
db.TestDb.CreateOrEditWorkspaceRepository(repository)
function e.gdb.TestDb.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid, repository_uuid)
functionr.Delete("/{workspace_uuid}/repository/{uuid}", workspaceHandlers.DeleteWorkspaceRepository)
as a reference, the test routeworkspace.Uuid
, andrepository.Uuid
should be used as URL parameters for the routeAssertions
401
error if a user is not authorizeddb.TestDb.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid, repository_uuid)
, the function should return an empty object.Acceptance Criteria
Here is an example Real DB Test
The text was updated successfully, but these errors were encountered: