Implement initial test-run option (#113) #118
Reference in New Issue
Block a user
Delete Branch "mmarhin/autogits:initial-test-run"
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?
Changes introduced:
--test-runflag inmain.go.RedisMockinredis.gowith static data.HGetAllandScanTypefunctions to return sample data forpython313andautogits.This allows running the service locally using:
go run . --debug --no-tls --test-runFixes #113
It's a good start, but maybe we can move the mock code to a new file, something like
redismock.go, so theredis.gofile doesn't change too much.And we can try to implement this in a more advanced way, we can try to make use of the go interfaces, so we can define a new struct, that implements the same interface than the redisClient.
We don't need to implement all the redisClient interfaces, just the two functions that we are using:
So,
*redis.Clientimplements that interface by default and our newMockRedistype should just implement those new methods and the global variable inredis.gocould be changed to use the interface:And just initialize accordingly depending on the
test-runflag.Thanks for the feedback and the guidance on using interfaces!
I have refactored the code to implement the
RedisClientinterface strategy as requested.Summary of changes:
RedisClientinterface inredis.go.redismock.go.redis.goto remove the boolean flags and conditional logic, relying on the interface polymorphism instead.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.