Skip to content

rspec like tests#40

Merged
sebastianwebber merged 7 commits intomainfrom
seba/use-rspec-like-tests
Feb 6, 2026
Merged

rspec like tests#40
sebastianwebber merged 7 commits intomainfrom
seba/use-rspec-like-tests

Conversation

@sebastianwebber
Copy link
Contributor

some refactors to use rspec like tests. pkg/tests is a simple wrap from the GoConvey package

Create pkg/tests package that wraps GoConvey with RSpec-like syntax
using Describe, Context, It, and Expect. This provides more readable
and maintainable test structure while keeping GoConvey's powerful
assertion matchers.

Benefits:
- Single import (. "github.com/pgconfig/api/pkg/tests")
- Familiar RSpec syntax for better readability
- Re-exports all GoConvey matchers (ShouldEqual, ShouldBeNil, etc)
- Cleaner hierarchical test output
- Easier for Ruby/RSpec developers to understand

Convert profile tests to demonstrate new testing style.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Convert all test files in cmd/ package to use new BDD testing style
with hybrid approach combining table-driven tests and RSpec-like
structure. This improves test readability while maintaining the
efficiency of table-driven patterns.

Changes:
- cmd/api/main_test.go: Simple BDD conversion
- cmd/api/handlers/v1/config_test.go: Hybrid with captured args to
  avoid goroutine assertion issues in Fiber handlers
- cmd/pgconfigctl/main_test.go: Compact table format inside It block

Benefits:
- More descriptive test output with nested contexts
- Maintains test table efficiency for multiple cases
- Consistent testing style across codebase
- 63 lines removed through more concise test structure

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Convert remaining input package tests and version tests to RSpec-style
BDD format. Both packages already used GoConvey, just needed import
updates and structure improvements.

Changes:
- pkg/input/bytes: Use Context/It with hybrid table-driven approach
  for formatting tests, keeps test data compact
- pkg/version: Simple Describe/It conversion

Both maintain the same test coverage with more readable structure.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Fix "go: no such tool covdata" error when running tests with coverage
in Go 1.25. This is a known issue where the covdata tool cannot be
found with GOTOOLCHAIN=auto.

Reference: golang/go#75031
Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Convert worker_test.go to use the new BDD-style test framework with
Describe/Context/It structure. Maintain hybrid approach with compact
table-driven tests inside It blocks for efficiency.

Reduces test code from 136 to 53 lines while improving readability
and maintaining all 27 assertions.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Convert all three format tests (alter_test.go, conf_test.go,
sg_config_test.go) to use BDD-style Describe/It structure for
improved readability and consistency with project test standards.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Convert all 7 rules test files to use BDD-style Describe/Context/It
structure. Maintain hybrid approach with compact table-driven tests
where appropriate for efficiency.

Major improvements:
- aio_test: 292 to 62 lines (230 lines removed)
- compute_test: Consolidated into 2 focused tests
- os_test: Better organization with Windows-specific Context
- version_test: Clear Context groupings per PostgreSQL version

All 148 assertions passing.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
@sebastianwebber sebastianwebber merged commit 0489fd7 into main Feb 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant