Commit 5edb5e9
Remove Viperize from storage backend tests (#7712)
## Summary
This PR successfully removes all usage of `config.Viperize` from tests
under `internal/storage/...`. According to the issue, these tests should
use direct config struct initialization instead of flag-based
configuration via Viperize, as CLI flag-based configuration for storage
backends has been removed in recent PRs.
## Changes Made
### Modified Test Files:
1. ~~**internal/storage/v1/memory/options_test.go**~~ - *Removed in main
branch (v1/memory implementation deleted)*
2. **internal/storage/v1/badger/options_test.go**: Removed Viperize
usage, tests now create `Config` structs directly (3 tests)
3. **internal/storage/v1/grpc/options_test.go**: Removed Viperize usage,
tests now create `Config` structs directly (3 tests)
4. **internal/storage/metricstore/prometheus/options_test.go**: Removed
Viperize usage, tests now create `Configuration` structs directly (2
tests)
5. **internal/storage/v1/elasticsearch/options_test.go**: Removed
Viperize usage from 11 tests. Also removed two tests that tested flag
registration behavior, and skipped one test that tested flag parsing
error handling (no longer relevant).
### Test Coverage
- All existing tests continue to pass with 100% success rate
- Tests verify the same behavior as before - just using direct config
initialization instead of flag parsing
- Total of 19 tests refactored across 4 files (memory tests removed with
v1/memory deletion)
### Code Quality Improvements
- Removed unused imports (fmt, flag, config packages)
- Added clarifying comments for date layout format strings
- Improved assertion logic clarity using explicit boolean conditions
- Fixed TestAuthenticationConditionalCreation to properly validate
expected values
## Validation
✅ All storage tests pass successfully:
- `internal/storage/v1/elasticsearch/...` - PASS
- `internal/storage/v1/badger/...` - PASS
- `internal/storage/v1/grpc/...` - PASS
- `internal/storage/metricstore/prometheus/...` - PASS
## Conflict Resolution
Resolved conflict where `internal/storage/v1/memory/options_test.go` was
deleted in main branch (v1/memory implementation removed in #7711).
**Rebased onto main branch** to keep PR history clean showing only 5
file changes.
---
- [x] Understand the issue and current code structure
- [x] Remove Viperize usage from
internal/storage/v1/grpc/options_test.go (3 tests)
- [x] Remove Viperize usage from
internal/storage/v1/elasticsearch/options_test.go (11 tests)
- [x] Remove Viperize usage from
internal/storage/v1/badger/options_test.go (3 tests)
- [x] ~~Remove Viperize usage from
internal/storage/v1/memory/options_test.go (1 test)~~ - File removed in
main
- [x] Remove Viperize usage from
internal/storage/metricstore/prometheus/options_test.go (2 tests)
- [x] Run tests to verify changes work correctly
- [x] Code review and address feedback
- [x] Rebase onto main branch
- [x] Fix test validation in TestAuthenticationConditionalCreation
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> in internal/config/config.go there is a function Viperize. It is only
used in tests. In recent PRs we removed all support for CLI flag based
configuration for storage backends so no tests under
internal/storage/... should be using Viperize and the corresponding
initialization of the factories via viper, they should be using direct
initialization via config struct.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: yurishkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>1 parent 1b5a167 commit 5edb5e9
File tree
12 files changed
+408
-1158
lines changed- internal/storage
- metricstore/prometheus
- v1
- badger
- elasticsearch
- grpc
12 files changed
+408
-1158
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
142 | 141 | | |
143 | 142 | | |
144 | 143 | | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | | - | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
24 | 22 | | |
25 | | - | |
26 | | - | |
27 | 23 | | |
28 | 24 | | |
29 | 25 | | |
30 | 26 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 27 | + | |
| 28 | + | |
41 | 29 | | |
42 | 30 | | |
43 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
26 | 20 | | |
27 | 21 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
38 | 34 | | |
39 | 35 | | |
40 | 36 | | |
| |||
46 | 42 | | |
47 | 43 | | |
48 | 44 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 45 | + | |
54 | 46 | | |
55 | 47 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 36 | | |
42 | 37 | | |
43 | 38 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments