obs-status-service: add --test-run using interface-based Redis mock (fixes #113) #123
Reference in New Issue
Block a user
Delete Branch "schrodinger/autogits:issue-113"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds a --test-run mode to obs-status-service to allow local development without requiring access to OBS Redis.
The implementation follows an interface-based design for the Redis client, allowing a clean separation between the real Redis client and a mock implementation (redismock.go), while keeping production logic unchanged.
This approach avoids conditional logic in the core code paths and aligns with the design discussed in #113.
Fixes #113.
@@ -21,2 +26,3 @@if err != nil {panic(err)common.LogError("Invalid Redis URL", err)returnWhy no more panic()?
I removed panic because I think that this code runs in a long-lived service so like any invalid Redis URL might give a runtime error, so logging the error and exiting cleanly felt more appropriate than crashing with a stack trace.
This also keeps the behavior consistent with the --test-run mode, where we want predictable startup failures instead of panics.
If you prefer keeping panic here for consistency with the rest of the codebase, I’m happy to switch it back.
Invalid Redis URL means we cannot start so it's fine to panic(). in *testRun you're already not calling this function anyway. Maybe have an error log here too and then panic.
It's long running only when it has an actual URL to try.
Ok I understand, thanks for the clarification!
I’ve updated RedisConnect to panic on an invalid Redis URL.
bb37ea8718toac19fecf01ac19fecf01tod563763f63View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.