-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Draft
Copilot
wants to merge
13
commits into
main
Choose a base branch
from
copilot/update-tests-lockdown-cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+589
−88
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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]>
Copilot
AI
changed the title
[WIP] Update tests to use lockdown cache initialization
Initialize lockdown cache singleton once per test function
Nov 18, 2025
Copilot finished work on behalf of
JoannaaKL
November 18, 2025 12:50
|
Код потрібно вставити готовий |
|
func Test_GetIssue(t testing.T) { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.