Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: unit tests for api layer #4161

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
20 changes: 18 additions & 2 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ can also be set by environment variables so you don't have to worry about the ru
each time.

## Configuration via TOML file
You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file.
You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file.

For example, to configure the server using a file named `config_example.toml`, you would run the following command:

```bash
go run . --config config_example.toml
```

To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file.
To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file.

## API

Expand All @@ -41,3 +41,19 @@ resources and take a look at our documentation.

Currently, you can also just open your browser on [http://localhost:8080](http://localhost:8080)
to see our debug client. We'll disable it once everything got stable.


## Testing and Mockery

At a certain point, it is more convenient to use a framework to generate mocks for interfaces.
This is where the use of Mockery comes into play (https://vektra.github.io/mockery/latest/installation/).
Depending on the operating system (macOS via Homebrew),
install Mockery and run it in the directory with .mockery.yaml (mockery). The mocks in the mocks directory will be automatically regenerated.

```bash
# switch to src directory
# and just run mockery to refresh the mocks
mockery
```

Configuration of mockery is described in the .mockery.yaml file.
20 changes: 20 additions & 0 deletions server/src/.mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
with-expecter: true
dir: mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_" }}
mockname: "Mock{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
filename: "mock_{{.InterfaceName}}.go"
resolve-type-alias: false
issue-845-fix: true
packages:
# configuration on package level
scrumlr.io/server/services:
# configuration on interface level
interfaces:
Boards:
all: true
BoardSessions:
all: true
Notes:
all: true
Votings:
all: true
2 changes: 1 addition & 1 deletion server/src/api/boards.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *Server) createBoard(w http.ResponseWriter, r *http.Request) {

b, err := s.boards.Create(r.Context(), body)
if err != nil {
common.Throw(w, r, common.BadRequestError(err))
common.Throw(w, r, err)
return
}

Expand Down
Loading
Loading