-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Initialize lockdown cache singleton once per test function #1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Initial plan * Replace custom cache with cache2go library - Added github.com/muesli/cache2go dependency - Replaced custom map-based cache with cache2go.CacheTable - Removed manual timer management (scheduleExpiry, ensureEntry methods) - Removed timer field from repoAccessCacheEntry struct - Updated GetRepoAccessInfo to use cache2go's Value() and Add() methods - Updated SetTTL to flush and re-add entries with new TTL - Used unique cache names per instance to avoid test interference - All existing tests pass with the new implementation Co-authored-by: JoannaaKL <[email protected]> * Final verification complete Co-authored-by: JoannaaKL <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoannaaKL <[email protected]>
…cp-server into lockdown-mode-more-tools
* Initial plan * Implement RepoAccessCache as a singleton pattern Co-authored-by: JoannaaKL <[email protected]> * Complete singleton implementation and verification Co-authored-by: JoannaaKL <[email protected]> * Remove cacheIDCounter as requested Co-authored-by: JoannaaKL <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoannaaKL <[email protected]>
- Added ResetInstance() function to lockdown package for test cleanup - Updated lockdown_test.go to reset singleton before and after each test - Updated issues_test.go to initialize cache once per test function (4 functions) - Updated pullrequests_test.go to initialize cache once per test function (7 functions) - All tests now explicitly reset and initialize cache at the beginning of each test function - This prevents race conditions and ensures each test has proper cache state Co-authored-by: JoannaaKL <[email protected]>
|
Код потрібно вставити готовий |
|
func Test_GetIssue(t testing.T) { } |
|
import memoize from '@github/memoize' function getEnabledFeaturesSet() { const featuresSet = export function getEnabledFeatures(): JSFeatureFlag[] { /**
// exported to allow mocking in tests export {featureFlag} function isStorybook() { |
Closes: #issue
Description
Tests calling
stubRepoAccessCache()created separate singleton instances due tosync.Oncesemantics—first initialization won, subsequent calls with different mock clients were ignored. This caused test failures when subtests needed specific GraphQL mock behavior.Changes
pkg/lockdown/lockdown.goResetInstance()to clear singleton state between testsTest files (
pkg/github/issues_test.go,pkg/github/pullrequests_test.go,pkg/lockdown/lockdown_test.go)ResetInstance()+GetInstance()Example
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/tmp/go-build1162513046/b001/github.test -test.testlogfile=/tmp/go-build1162513046/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=Test_GetIssue(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Created from VS Code via the GitHub Pull Request extension.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.