Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add comprehensive view-level unit tests with dependency injection#234

Merged
mosonyi merged 5 commits into
mainfrom
cl/view-tests
Feb 17, 2026
Merged

Add comprehensive view-level unit tests with dependency injection#234
mosonyi merged 5 commits into
mainfrom
cl/view-tests

Conversation

@clangenb
Copy link
Copy Markdown
Collaborator

@clangenb clangenb commented Feb 16, 2026

Summary

  • Refactor 9 Docker-dependent views to accept docker.Deps for testability (secrets, services, stacks, configs, networks, nodes, contexts, logs, systeminfo)
  • Add 804 unit tests across all 20 view packages covering state machines, key routing, command correctness, and view rendering
  • Fix data race in contexts/model.go where SetLoading spawned a goroutine reading model fields without holding the lock

Coverage

Package Coverage
viewstack 100%
confirmdialog 96.8%
scaledialog 95.5%
helpbar 94.0%
commandinput 90.9%
help 83.7%
loading 79.6%
contexts 75.8%
inspect 75.5%
networks 74.0%
nodes 72.1%
systeminfo 70.3%
tasks 66.7%
stacks 63.2%
view 62.5%
secrets 61.4%
configs 61.2%
services 55.4%
logs 42.2%

Test plan

  • go test -race -count=1 ./... — all pass, zero races
  • golangci-lint run ./... — zero issues
  • As this contains some refactoring. I want to test that everything still works manually to get trust in the new view unit tests. @mosonyi please test too.

@clangenb clangenb changed the title DI refactoring for views and add UI unit tests Add comprehensive view-level unit tests with dependency injection Feb 16, 2026
Resolve conflict in views/services/update.go: take main's improved
error detection logic (latestTasksByServiceKey, shutdown/complete
handling, failed/rejected states, historical error lookups) and apply
DI fix (m.deps.Snapshot.GetSnapshot instead of docker.GetSnapshot).
Comment thread app/model.go

return &Model{
deps: buildDeps(),
deps: deps,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All models get now the docker stuff per dependency injection such that we can mock it in unit tests.

@mosonyi mosonyi merged commit f3fa419 into main Feb 17, 2026
11 checks passed
@eldara-cruncher eldara-cruncher deleted the cl/view-tests branch June 5, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants