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

Merged
merged 30 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1c0c734
basic test cases for api/columns
mateo-ivc May 22, 2024
38a9f81
add unit tests for board
mateo-ivc May 23, 2024
2315213
add unit tests for board
mateo-ivc May 24, 2024
73acd72
add unit tests for board
wischoepke Jan 15, 2025
21ad79d
chore: The first steps for the transition to mockery
wischoepke Jan 15, 2025
30c29c3
feat: commit mockery generated interface
wischoepke Jan 15, 2025
f8b418e
chore: generate only needed mocks and
wischoepke Jan 15, 2025
7ddeab7
refactor: replace test content structure with
wischoepke Jan 16, 2025
0ea7c49
refactor: remove commented code
wischoepke Jan 16, 2025
b24f6df
refactor: refactor notes tests with mockery mocks
wischoepke Jan 16, 2025
b721a02
refactor: replace custom mock implementations
wischoepke Jan 22, 2025
23495a8
Merge branch 'main' into mi/add-api-tests
Lennart01 Jan 27, 2025
c9f028e
basic test cases for api/columns
mateo-ivc May 22, 2024
5b9e46b
add unit tests for board
mateo-ivc May 23, 2024
ced8fc7
add unit tests for board
mateo-ivc May 24, 2024
92af42a
add unit tests for board
wischoepke Jan 15, 2025
73eb8eb
chore: The first steps for the transition to mockery
wischoepke Jan 15, 2025
75c65d9
feat: commit mockery generated interface
wischoepke Jan 15, 2025
cf0727a
chore: generate only needed mocks and
wischoepke Jan 15, 2025
1f8b1f3
refactor: replace test content structure with
wischoepke Jan 16, 2025
289a481
refactor: remove commented code
wischoepke Jan 16, 2025
8a44a89
refactor: refactor notes tests with mockery mocks
wischoepke Jan 16, 2025
a8bbdf9
refactor: replace custom mock implementations
wischoepke Jan 22, 2025
076c040
fix imports
mateo-ivc Feb 13, 2025
2e22403
Merge branch 'mi/add-api-tests' of github.com:inovex/scrumlr.io into …
mateo-ivc Feb 13, 2025
7af8f3d
add edit note test
mateo-ivc Feb 13, 2025
747a38a
add edit-note test
mateo-ivc Feb 17, 2025
7a1c4c6
fix linter errors
mateo-ivc Feb 17, 2025
7c66b47
Merge branch 'main' into mi/add-api-tests
mateo-ivc Feb 17, 2025
1ce338d
let test fail if not able to parse response
mateo-ivc Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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