fix go formatting

This commit is contained in:
Evan Jarrett
2025-10-28 22:06:03 -05:00
parent 9d773d484a
commit 5a3b3f3372
7 changed files with 45 additions and 46 deletions
+3 -3
View File
@@ -275,11 +275,11 @@ func TestUpsertCaptainRecord_Update(t *testing.T) {
updatedRecord := &HoldCaptainRecord{
HoldDID: "did:web:hold04.atcr.io", // Same DID
OwnerDID: "did:plc:eve222", // Changed owner
Public: true, // Changed to public
AllowAllCrew: true, // Changed allow all crew
Public: true, // Changed to public
AllowAllCrew: true, // Changed allow all crew
DeployedAt: "2025-03-01", // Changed date
Region: "ap-south-1", // Changed region
Provider: "azure", // Changed provider
Provider: "azure", // Changed provider
UpdatedAt: time.Now(),
}
+6 -6
View File
@@ -37,12 +37,12 @@ func (m *mockHoldAuthorizer) Authorize(holdDID, userDID, permission string) (boo
func TestRegistryContext_Fields(t *testing.T) {
// Create a sample RegistryContext
ctx := &RegistryContext{
DID: "did:plc:test123",
Handle: "alice.bsky.social",
HoldDID: "did:web:hold01.atcr.io",
PDSEndpoint: "https://bsky.social",
Repository: "debian",
ServiceToken: "test-token",
DID: "did:plc:test123",
Handle: "alice.bsky.social",
HoldDID: "did:web:hold01.atcr.io",
PDSEndpoint: "https://bsky.social",
Repository: "debian",
ServiceToken: "test-token",
ATProtoClient: &atproto.Client{
// Mock client - would need proper initialization in real tests
},
+3 -3
View File
@@ -544,9 +544,9 @@ func TestManifestStore_Get_HoldDIDTracking(t *testing.T) {
ociManifest := []byte(`{"schemaVersion":2}`)
tests := []struct {
name string
manifestResp string
expectedHoldDID string
name string
manifestResp string
expectedHoldDID string
}{
{
name: "tracks HoldDID from new format",
+5 -5
View File
@@ -11,11 +11,11 @@ import (
// Shared PDS instances for read-only tests
var (
sharedEmptyPDS *pds.HoldPDS
sharedPublicPDS *pds.HoldPDS
sharedPrivatePDS *pds.HoldPDS
sharedAllowCrewPDS *pds.HoldPDS
sharedTempDir string
sharedEmptyPDS *pds.HoldPDS
sharedPublicPDS *pds.HoldPDS
sharedPrivatePDS *pds.HoldPDS
sharedAllowCrewPDS *pds.HoldPDS
sharedTempDir string
)
// TestMain sets up shared test fixtures
+20 -20
View File
@@ -20,16 +20,16 @@ import (
// Used by AppView to authorize access to remote holds
// Implements caching for captain records to reduce XRPC calls
type RemoteHoldAuthorizer struct {
db *sql.DB
httpClient *http.Client
cacheTTL time.Duration // TTL for captain record cache
recentDenials sync.Map // In-memory cache for first denials
stopCleanup chan struct{} // Signal to stop cleanup goroutine
testMode bool // If true, use HTTP for local DIDs
firstDenialBackoff time.Duration // Backoff duration for first denial (default: 10s)
cleanupInterval time.Duration // Cleanup goroutine interval (default: 10s)
cleanupGracePeriod time.Duration // Grace period before cleanup (default: 5s)
dbBackoffDurations []time.Duration // Backoff durations for DB denials (default: [1m, 5m, 15m, 1h])
db *sql.DB
httpClient *http.Client
cacheTTL time.Duration // TTL for captain record cache
recentDenials sync.Map // In-memory cache for first denials
stopCleanup chan struct{} // Signal to stop cleanup goroutine
testMode bool // If true, use HTTP for local DIDs
firstDenialBackoff time.Duration // Backoff duration for first denial (default: 10s)
cleanupInterval time.Duration // Cleanup goroutine interval (default: 10s)
cleanupGracePeriod time.Duration // Grace period before cleanup (default: 5s)
dbBackoffDurations []time.Duration // Backoff durations for DB denials (default: [1m, 5m, 15m, 1h])
}
// denialEntry stores timestamp for in-memory first denials
@@ -40,9 +40,9 @@ type denialEntry struct {
// NewRemoteHoldAuthorizer creates a new remote authorizer for AppView with production defaults
func NewRemoteHoldAuthorizer(db *sql.DB, testMode bool) HoldAuthorizer {
return NewRemoteHoldAuthorizerWithBackoffs(db, testMode,
10*time.Second, // firstDenialBackoff
10*time.Second, // cleanupInterval
5*time.Second, // cleanupGracePeriod
10*time.Second, // firstDenialBackoff
10*time.Second, // cleanupInterval
5*time.Second, // cleanupGracePeriod
[]time.Duration{ // dbBackoffDurations
1 * time.Minute,
5 * time.Minute,
@@ -60,13 +60,13 @@ func NewRemoteHoldAuthorizerWithBackoffs(db *sql.DB, testMode bool, firstDenialB
httpClient: &http.Client{
Timeout: 10 * time.Second,
},
cacheTTL: 1 * time.Hour, // 1 hour cache TTL
stopCleanup: make(chan struct{}),
testMode: testMode,
firstDenialBackoff: firstDenialBackoff,
cleanupInterval: cleanupInterval,
cleanupGracePeriod: cleanupGracePeriod,
dbBackoffDurations: dbBackoffDurations,
cacheTTL: 1 * time.Hour, // 1 hour cache TTL
stopCleanup: make(chan struct{}),
testMode: testMode,
firstDenialBackoff: firstDenialBackoff,
cleanupInterval: cleanupInterval,
cleanupGracePeriod: cleanupGracePeriod,
dbBackoffDurations: dbBackoffDurations,
}
// Start cleanup goroutine for in-memory denials
+2 -3
View File
@@ -288,11 +288,11 @@ func TestIsCrewMember_DenialBackoff_FirstDenial(t *testing.T) {
// Create authorizer with fast backoffs for testing (10ms instead of 10s)
remote := NewRemoteHoldAuthorizerWithBackoffs(
testDB,
false, // testMode
false, // testMode
10*time.Millisecond, // firstDenialBackoff (10ms instead of 10s)
50*time.Millisecond, // cleanupInterval (50ms instead of 10s)
50*time.Millisecond, // cleanupGracePeriod (50ms instead of 5s)
[]time.Duration{ // dbBackoffDurations (fast test values)
[]time.Duration{ // dbBackoffDurations (fast test values)
10 * time.Millisecond,
20 * time.Millisecond,
30 * time.Millisecond,
@@ -389,4 +389,3 @@ func TestCheckReadAccess_PublicHold(t *testing.T) {
_ = server
}
+6 -6
View File
@@ -49,12 +49,12 @@ func TestInitLogger(t *testing.T) {
defer slog.SetDefault(originalLogger)
tests := []struct {
name string
level string
shouldLogDebug bool
shouldLogInfo bool
shouldLogWarn bool
shouldLogError bool
name string
level string
shouldLogDebug bool
shouldLogInfo bool
shouldLogWarn bool
shouldLogError bool
}{
{
name: "debug level logs all",