Problem
Worker specs exist but are marked pending, resulting in no test coverage for workers.
Impact
- Cannot verify worker behavior in CI
- Regression risk when modifying workers
- No confidence in worker reliability
Files Requiring Implementation
1. spec/workers/index_shard_worker_spec.cr
Currently has 3 pending tests:
- "processes shard metadata correctly"
- "enqueues BuildDocsWorker after indexing"
- "handles errors gracefully"
2. spec/workers/build_docs_worker_spec.cr
Status: Check if tests exist and are pending
3. spec/workers/update_dependencies_worker_spec.cr
Status: Check if tests exist and are pending
Requirements
Test Coverage Needed
- Success paths: Worker completes successfully
- Error handling: Worker handles failures gracefully
- External dependencies: Mock GitHub API, MinIO, Redis
- Worker chaining: Verify workers enqueue next workers
- Idempotency: Same job run multiple times produces same result
Mocking Strategy
# Mock GitHub API
class MockGitHubClient
def get_shard_yml(repo : String, ref : String) : String
# Return fixture data
end
end
# Mock MinIO
class MockMinIOClient
def upload(bucket : String, key : String, data : IO) : Nil
# Track uploads for assertions
end
end
# Use test Redis instance
Mosquito.configure do |settings|
settings.redis_url = ENV["TEST_REDIS_URL"]
end
Test Structure
describe IndexShardWorker do
it "processes shard metadata correctly" do
worker = IndexShardWorker.new
worker.shard_name = "example"
worker.version = "1.0.0"
# Mock external calls
# Run worker
# Assert database records created
# Assert metadata extracted correctly
end
it "enqueues BuildDocsWorker after indexing" do
# Run IndexShardWorker
# Assert BuildDocsWorker was enqueued
end
it "handles errors gracefully" do
# Mock failure condition
# Run worker
# Assert error logged
# Assert job marked as failed
end
end
Implementation Steps
- Remove
pending blocks from all worker specs
- Implement mock classes for external dependencies
- Write assertions for each test case
- Run tests locally and verify they pass
- Add tests to CI pipeline
Priority
MEDIUM - Improves confidence in worker reliability
Application
CrystalShards.org
Acceptance Criteria
Problem
Worker specs exist but are marked
pending, resulting in no test coverage for workers.Impact
Files Requiring Implementation
1. spec/workers/index_shard_worker_spec.cr
Currently has 3 pending tests:
2. spec/workers/build_docs_worker_spec.cr
Status: Check if tests exist and are pending
3. spec/workers/update_dependencies_worker_spec.cr
Status: Check if tests exist and are pending
Requirements
Test Coverage Needed
Mocking Strategy
Test Structure
Implementation Steps
pendingblocks from all worker specsPriority
MEDIUM - Improves confidence in worker reliability
Application
CrystalShards.org
Acceptance Criteria
pendingblocks removed from worker specs