Documentation
¶
Index ¶
- func AssertActionTypeConstantsPattern(t *testing.T, actionTypes []interface{}, expectedValues []ConstantTest)
- func AssertCommandExecution(t *testing.T, err error, output string, expectedPatterns ...string)
- func AssertCommandWithFlags(t *testing.T, cmd *cobra.Command, expectedFlags ...string)
- func AssertConfigContent(t *testing.T, content []byte, expectedFields ...string)
- func AssertConfigFileOperations(t *testing.T, configPath string, operations ...ConfigOperation)
- func AssertConstantArrayNotEmpty(t *testing.T, constants []interface{}, constantType string)
- func AssertConstantValues(t *testing.T, tests []ConstantTest)
- func AssertDefaultOptions(t *testing.T, opts DevEnvOptions)
- func AssertDevEnvCommand(t *testing.T, cmd *cobra.Command, expectedUse, expectedShort string)
- func AssertDirectoryStructure(t *testing.T, basePath string, expectedPaths []string)
- func AssertEnvironmentSetup(t *testing.T, requirements EnvironmentRequirements)
- func AssertErrorTypeConstantsPattern(t *testing.T, errorTypes []interface{}, expectedValues []ConstantTest)
- func AssertIntegrationTest(t *testing.T, testName string, testFunc func(t *testing.T) error)
- func AssertPathExists(t *testing.T, path string)
- func AssertPathNotExists(t *testing.T, path string)
- func AssertServiceHealth(t *testing.T, healthCheck func() (bool, error), timeout time.Duration)
- func AssertStatusConstantsPattern(t *testing.T, statuses []interface{}, expectedValues []ConstantTest)
- func RetryOperation(t *testing.T, operation func() error, maxRetries int, delay time.Duration) error
- func RunAPITestPattern(t *testing.T, pattern APITestPattern)
- func RunFileOperationTest(t *testing.T, test FileOperationTest)
- type APITestPattern
- type BasicRepoCreator
- type BasicRepoOptions
- type BranchConfig
- type BranchInfo
- type BranchManager
- func (bm *BranchManager) CreateBranchScenario(ctx context.Context, repoPath string, scenario BranchScenario) error
- func (bm *BranchManager) CreateDivergentBranchesScenario(ctx context.Context, repoPath string) error
- func (bm *BranchManager) CreateGitFlowScenario(ctx context.Context, repoPath string) error
- func (bm *BranchManager) GetBranchInfo(ctx context.Context, repoPath string) ([]string, error)
- func (bm *BranchManager) SwitchToBranch(ctx context.Context, repoPath, branchName string) error
- type BranchScenario
- type BranchState
- type BranchStrategyTester
- func (bst *BranchStrategyTester) TestAllStrategies(ctx context.Context, baseRepoPath string) error
- func (bst *BranchStrategyTester) TestPullStrategy(ctx context.Context, repoPath string) error
- func (bst *BranchStrategyTester) TestRebaseStrategy(ctx context.Context, repoPath string) error
- func (bst *BranchStrategyTester) TestResetStrategy(ctx context.Context, repoPath string) error
- func (bst *BranchStrategyTester) TestStrategy(ctx context.Context, baseRepoPath, strategy string) error
- type ChangeType
- type CommitConfig
- type CommonTestPaths
- type ConfigOperation
- type ConfigOperationType
- type ConflictRepoOptions
- type ConflictScenario
- type ConflictStatus
- type ConflictType
- type ConflictingFile
- type ConstantTest
- type DefaultMockRepoFactory
- func (f *DefaultMockRepoFactory) CreateBasicRepos(ctx context.Context, opts BasicRepoOptions) error
- func (f *DefaultMockRepoFactory) CreateConflictRepos(ctx context.Context, opts ConflictRepoOptions) error
- func (f *DefaultMockRepoFactory) CreateSpecialRepos(ctx context.Context, opts SpecialRepoOptions) error
- type DevEnvOptions
- type E2ETestConfig
- type E2ETestSuite
- type EnvironmentRequirements
- type ErrorRule
- type ErrorType
- type ExpectedOutcome
- type FileOperationTest
- type FileRename
- type GitLFSSimulator
- func (lfs *GitLFSSimulator) CreateLFSRepository(ctx context.Context, repoPath string, config LFSConfig) error
- func (lfs *GitLFSSimulator) CreateSimpleLFSRepo(ctx context.Context, repoPath string) error
- func (lfs *GitLFSSimulator) GetLFSStatus(ctx context.Context, repoPath string) (LFSStatus, error)
- func (lfs *GitLFSSimulator) IsLFSAvailable(ctx context.Context) bool
- type GitOperationSimulator
- type IntegrationTestHelper
- type LFSConfig
- type LFSFile
- type LFSStatus
- type LargeRepoCreator
- func (c *LargeRepoCreator) CreateLargeRepo(ctx context.Context, opts LargeRepoOptions) error
- func (c *LargeRepoCreator) CreateLargeRepoSimple(ctx context.Context, repoPath string, sizeMB int64) error
- func (c *LargeRepoCreator) CreateLargeRepoWithHistory(ctx context.Context, repoPath string) error
- func (c *LargeRepoCreator) CreateRepoWithBinaryFiles(ctx context.Context, repoPath string) error
- func (c *LargeRepoCreator) GetRepoSize(repoPath string) (int64, error)
- type LargeRepoOptions
- type LocalChange
- type LocalChangesSimulator
- func (lcs *LocalChangesSimulator) CreateConflictedWorkingDirectory(ctx context.Context, repoPath string) error
- func (lcs *LocalChangesSimulator) CreateDirtyWorkingDirectory(ctx context.Context, repoPath string) error
- func (lcs *LocalChangesSimulator) CreateMixedStateRepository(ctx context.Context, repoPath string) error
- func (lcs *LocalChangesSimulator) CreateWorkingDirectoryState(ctx context.Context, repoPath string, state WorkingDirectoryState) error
- func (lcs *LocalChangesSimulator) GetWorkingDirectoryStatus(ctx context.Context, repoPath string) (WorkingDirectoryStatus, error)
- type LocalFileChange
- type MergeConfig
- type MergeConflictGenerator
- func (mcg *MergeConflictGenerator) CreateComplexConflict(ctx context.Context, repoPath string) error
- func (mcg *MergeConflictGenerator) CreateConflictScenario(ctx context.Context, repoPath string, scenario ConflictScenario) error
- func (mcg *MergeConflictGenerator) CreateDivergedBranchesConflict(ctx context.Context, repoPath string) error
- func (mcg *MergeConflictGenerator) CreateSimpleContentConflict(ctx context.Context, repoPath string) error
- func (mcg *MergeConflictGenerator) GetConflictStatus(ctx context.Context, repoPath string) (ConflictStatus, error)
- type MockRepoFactory
- type MockTestHelper
- type NetworkErrorSimulator
- func (nes *NetworkErrorSimulator) AddErrorRule(rule ErrorRule)
- func (nes *NetworkErrorSimulator) ClearErrorRules()
- func (nes *NetworkErrorSimulator) CreateRecoveryScenario(ctx context.Context, initialFailures int) *NetworkErrorSimulator
- func (nes *NetworkErrorSimulator) GetRequestStats() RequestStats
- func (nes *NetworkErrorSimulator) SimulateGitCloneTimeout(ctx context.Context) *NetworkErrorSimulator
- func (nes *NetworkErrorSimulator) SimulateHTTPErrors(ctx context.Context) *NetworkErrorSimulator
- func (nes *NetworkErrorSimulator) SimulateIntermittentConnection(ctx context.Context, failureRate float64) *NetworkErrorSimulator
- func (nes *NetworkErrorSimulator) StartServer() string
- func (nes *NetworkErrorSimulator) StopServer()
- type PreMergeAction
- type RemoteChange
- type RequestStats
- type SpecialRepoOptions
- type StandardRepoCreator
- func (c *StandardRepoCreator) CreateDevelopmentRepo(ctx context.Context, repoPath string) error
- func (c *StandardRepoCreator) CreateProjectRepo(ctx context.Context, repoPath string, projectType string) error
- func (c *StandardRepoCreator) CreateStandardRepo(ctx context.Context, opts StandardRepoOptions) error
- type StandardRepoOptions
- type StrategyTestCase
- type SubmoduleConfig
- type SubmoduleManager
- func (sm *SubmoduleManager) CreateNestedSubmodules(ctx context.Context, basePath string) error
- func (sm *SubmoduleManager) CreateRepositoryWithSubmodules(ctx context.Context, parentPath string, submodules []SubmoduleConfig) error
- func (sm *SubmoduleManager) GetSubmoduleStatus(ctx context.Context, repoPath string) ([]SubmoduleStatus, error)
- func (sm *SubmoduleManager) UpdateSubmodules(ctx context.Context, repoPath string) error
- type SubmoduleStatus
- type ValidationCheck
- type WorkingDirectoryState
- type WorkingDirectoryStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertActionTypeConstantsPattern ¶
func AssertActionTypeConstantsPattern(t *testing.T, actionTypes []interface{}, expectedValues []ConstantTest)
AssertActionTypeConstantsPattern tests common action type constant patterns.
func AssertCommandExecution ¶
AssertCommandExecution verifies command execution results.
func AssertCommandWithFlags ¶
AssertCommandWithFlags verifies that a command has expected flags.
func AssertConfigContent ¶
AssertConfigContent verifies common configuration content patterns.
func AssertConfigFileOperations ¶
func AssertConfigFileOperations(t *testing.T, configPath string, operations ...ConfigOperation)
AssertConfigFileOperations tests common config file operations.
func AssertConstantArrayNotEmpty ¶
AssertConstantArrayNotEmpty verifies that all constants in an array are not empty.
func AssertConstantValues ¶
func AssertConstantValues(t *testing.T, tests []ConstantTest)
AssertConstantValues verifies specific constant values.
func AssertDefaultOptions ¶
func AssertDefaultOptions(t *testing.T, opts DevEnvOptions)
AssertDefaultOptions verifies that default options have expected values.
func AssertDevEnvCommand ¶
AssertDevEnvCommand verifies that a dev-env command has the expected structure.
func AssertDirectoryStructure ¶
AssertDirectoryStructure verifies expected directory structure.
func AssertEnvironmentSetup ¶
func AssertEnvironmentSetup(t *testing.T, requirements EnvironmentRequirements)
AssertEnvironmentSetup verifies common environment setup requirements.
func AssertErrorTypeConstantsPattern ¶
func AssertErrorTypeConstantsPattern(t *testing.T, errorTypes []interface{}, expectedValues []ConstantTest)
AssertErrorTypeConstantsPattern tests common error type constant patterns.
func AssertIntegrationTest ¶
AssertIntegrationTest runs a common integration test pattern.
func AssertPathExists ¶
AssertPathExists verifies that a path exists.
func AssertPathNotExists ¶
AssertPathNotExists verifies that a path does not exist.
func AssertServiceHealth ¶
AssertServiceHealth checks common service health patterns.
func AssertStatusConstantsPattern ¶
func AssertStatusConstantsPattern(t *testing.T, statuses []interface{}, expectedValues []ConstantTest)
AssertStatusConstantsPattern tests common status constant patterns.
func RetryOperation ¶
func RetryOperation(t *testing.T, operation func() error, maxRetries int, delay time.Duration) error
RetryOperation retries an operation with common retry logic.
func RunAPITestPattern ¶
func RunAPITestPattern(t *testing.T, pattern APITestPattern)
RunAPITestPattern executes a common API test pattern.
func RunFileOperationTest ¶
func RunFileOperationTest(t *testing.T, test FileOperationTest)
RunFileOperationTest executes a file operation test with common setup/cleanup.
Types ¶
type APITestPattern ¶
type APITestPattern struct {
Name string
Setup func(t *testing.T) interface{}
Execute func(t *testing.T, input interface{}) (interface{}, error)
Verify func(t *testing.T, result interface{}, err error)
ExpectedType interface{}
}
APITestPattern represents a common API test pattern.
type BasicRepoCreator ¶
type BasicRepoCreator struct {
// contains filtered or unexported fields
}
BasicRepoCreator provides functionality for creating basic Git repositories with various initial states for testing synclone operations.
func NewBasicRepoCreator ¶
func NewBasicRepoCreator() *BasicRepoCreator
NewBasicRepoCreator creates a new BasicRepoCreator instance.
func (*BasicRepoCreator) CreateEmptyRepo ¶
func (c *BasicRepoCreator) CreateEmptyRepo(ctx context.Context, repoPath string) error
CreateEmptyRepo creates a Git repository with just git init This simulates the most basic repository state.
func (*BasicRepoCreator) CreateMinimalRepo ¶
func (c *BasicRepoCreator) CreateMinimalRepo(ctx context.Context, repoPath string) error
CreateMinimalRepo creates a repository with a single initial commit This simulates the most common starting state for repositories.
func (*BasicRepoCreator) CreateRepoWithFiles ¶
func (c *BasicRepoCreator) CreateRepoWithFiles(ctx context.Context, repoPath string, files map[string]string) error
CreateRepoWithFiles creates a repository with multiple files This simulates repositories with actual content.
type BasicRepoOptions ¶
BasicRepoOptions defines options for creating basic test repositories.
type BranchConfig ¶
type BranchConfig struct {
Name string
StartingFrom string // Branch to branch from (empty for main/master)
Commits []CommitConfig
}
BranchConfig defines configuration for a single branch.
type BranchInfo ¶
type BranchInfo struct {
LastCommit string
AheadCount int // commits ahead of remote
BehindCount int // commits behind remote
HasLocalCommits bool
}
BranchInfo contains information about a specific branch.
type BranchManager ¶
type BranchManager struct {
// contains filtered or unexported fields
}
BranchManager provides functionality for managing Git branches and creating various branching scenarios for synclone testing.
func NewBranchManager ¶
func NewBranchManager() *BranchManager
NewBranchManager creates a new BranchManager instance.
func (*BranchManager) CreateBranchScenario ¶
func (bm *BranchManager) CreateBranchScenario(ctx context.Context, repoPath string, scenario BranchScenario) error
CreateBranchScenario creates a specific branching scenario.
func (*BranchManager) CreateDivergentBranchesScenario ¶
func (bm *BranchManager) CreateDivergentBranchesScenario(ctx context.Context, repoPath string) error
CreateDivergentBranchesScenario creates branches that have diverged significantly.
func (*BranchManager) CreateGitFlowScenario ¶
func (bm *BranchManager) CreateGitFlowScenario(ctx context.Context, repoPath string) error
CreateGitFlowScenario creates a Git Flow branching model scenario.
func (*BranchManager) GetBranchInfo ¶
GetBranchInfo returns information about all branches in the repository.
func (*BranchManager) SwitchToBranch ¶
func (bm *BranchManager) SwitchToBranch(ctx context.Context, repoPath, branchName string) error
SwitchToBranch switches to a specified branch.
type BranchScenario ¶
type BranchScenario struct {
Name string
Branches []BranchConfig
Merges []MergeConfig
Description string
}
BranchScenario defines a branching scenario for testing.
type BranchState ¶
type BranchState struct {
CurrentBranch string
Branches map[string]BranchInfo // branch name -> info
UncommittedChanges bool
ConflictingChanges bool
}
BranchState represents the state of a repository's branches.
type BranchStrategyTester ¶
type BranchStrategyTester struct {
// contains filtered or unexported fields
}
BranchStrategyTester tests different synclone strategies against various branch scenarios.
func NewBranchStrategyTester ¶
func NewBranchStrategyTester() *BranchStrategyTester
NewBranchStrategyTester creates a new BranchStrategyTester instance.
func (*BranchStrategyTester) TestAllStrategies ¶
func (bst *BranchStrategyTester) TestAllStrategies(ctx context.Context, baseRepoPath string) error
TestAllStrategies tests all synclone strategies against common scenarios.
func (*BranchStrategyTester) TestPullStrategy ¶
func (bst *BranchStrategyTester) TestPullStrategy(ctx context.Context, repoPath string) error
TestPullStrategy specifically tests the pull strategy.
func (*BranchStrategyTester) TestRebaseStrategy ¶
func (bst *BranchStrategyTester) TestRebaseStrategy(ctx context.Context, repoPath string) error
TestRebaseStrategy specifically tests the rebase strategy.
func (*BranchStrategyTester) TestResetStrategy ¶
func (bst *BranchStrategyTester) TestResetStrategy(ctx context.Context, repoPath string) error
TestResetStrategy specifically tests the reset strategy.
func (*BranchStrategyTester) TestStrategy ¶
func (bst *BranchStrategyTester) TestStrategy(ctx context.Context, baseRepoPath, strategy string) error
TestStrategy tests a specific synclone strategy.
type ChangeType ¶
type ChangeType int
ChangeType represents the type of file change.
const ( ChangeTypeModify ChangeType = iota ChangeTypeAdd ChangeTypeDelete ChangeTypeRename )
func (ChangeType) String ¶
func (ct ChangeType) String() string
String returns the string representation of ChangeType.
type CommitConfig ¶
type CommitConfig struct {
Message string
Files map[string]string // filename -> content
IsTag bool
TagName string
}
CommitConfig defines a commit to be made on a branch.
type CommonTestPaths ¶
CommonTestPaths provides standard test paths for different services.
func NewCommonTestPaths ¶
func NewCommonTestPaths(t *testing.T, serviceName string) CommonTestPaths
NewCommonTestPaths creates standard test paths in a temporary directory.
type ConfigOperation ¶
type ConfigOperation struct {
Type ConfigOperationType
Execute func(configPath string) error
}
ConfigOperation represents a configuration operation.
type ConfigOperationType ¶
type ConfigOperationType int
ConfigOperationType defines types of config operations.
const ( ConfigOpCreate ConfigOperationType = iota ConfigOpRead ConfigOpUpdate ConfigOpDelete )
type ConflictRepoOptions ¶
type ConflictRepoOptions struct {
BaseDir string
RepoName string
ConflictType string // "merge", "rebase", "diverged"
LocalChanges bool
}
ConflictRepoOptions defines options for creating conflict scenario repositories.
type ConflictScenario ¶
type ConflictScenario struct {
Name string
Description string
BaseBranch string
ConflictingBranch string
ConflictFiles []ConflictingFile
PreMergeSetup []PreMergeAction
}
ConflictScenario defines a merge conflict scenario.
type ConflictStatus ¶
type ConflictStatus struct {
HasConflicts bool
ConflictedFiles []string
UnmergedPaths []string
BothModified []string
BothAdded []string
DeletedByThem []string
DeletedByUs []string
}
ConflictStatus represents the current conflict state.
func (ConflictStatus) IsInMergeState ¶
func (cs ConflictStatus) IsInMergeState() bool
IsInMergeState returns true if the repository is in a merge state.
type ConflictType ¶
type ConflictType int
ConflictType represents the type of merge conflict.
const ( ConflictTypeContent ConflictType = iota // Both sides modified same lines ConflictTypeAddAdd // Both sides added same file ConflictTypeModifyDelete // One modified, one deleted ConflictTypeRename // Rename conflicts )
func (ConflictType) String ¶
func (ct ConflictType) String() string
String returns the string representation of ConflictType.
type ConflictingFile ¶
type ConflictingFile struct {
FilePath string
BaseContent string
BranchAContent string
BranchBContent string
ConflictType ConflictType
}
ConflictingFile represents a file that will have conflicts.
type ConstantTest ¶
type ConstantTest struct {
Name string
Expected interface{}
Actual interface{}
}
ConstantTest represents a constant value test case.
type DefaultMockRepoFactory ¶
type DefaultMockRepoFactory struct {
// contains filtered or unexported fields
}
DefaultMockRepoFactory implements MockRepoFactory interface.
func (*DefaultMockRepoFactory) CreateBasicRepos ¶
func (f *DefaultMockRepoFactory) CreateBasicRepos(ctx context.Context, opts BasicRepoOptions) error
CreateBasicRepos creates basic test repositories with standard Git structures.
func (*DefaultMockRepoFactory) CreateConflictRepos ¶
func (f *DefaultMockRepoFactory) CreateConflictRepos(ctx context.Context, opts ConflictRepoOptions) error
CreateConflictRepos creates repositories with conflict scenarios.
func (*DefaultMockRepoFactory) CreateSpecialRepos ¶
func (f *DefaultMockRepoFactory) CreateSpecialRepos(ctx context.Context, opts SpecialRepoOptions) error
CreateSpecialRepos creates repositories with special scenarios.
type DevEnvOptions ¶
DevEnvOptions represents common options structure for dev-env commands.
type E2ETestConfig ¶
type E2ETestConfig struct {
TestTimeout time.Duration
SkipCondition func() bool
SkipMessage string
SetupFunc func(t *testing.T) interface{}
CleanupFunc func(t *testing.T, data interface{})
RequiredEnvVars []string
}
E2ETestConfig represents common configuration for E2E tests.
type E2ETestSuite ¶
type E2ETestSuite struct {
// contains filtered or unexported fields
}
E2ETestSuite provides common E2E test functionality.
func NewE2ETestSuite ¶
func NewE2ETestSuite(t *testing.T, config E2ETestConfig) *E2ETestSuite
NewE2ETestSuite creates a new E2E test suite.
func (*E2ETestSuite) Cleanup ¶
func (e *E2ETestSuite) Cleanup()
Cleanup performs common E2E test cleanup.
func (*E2ETestSuite) GetSetupData ¶
func (e *E2ETestSuite) GetSetupData() interface{}
GetSetupData returns the data from setup function.
type EnvironmentRequirements ¶
type EnvironmentRequirements struct {
RequiredEnvVars []string
RequiredDirectories []string
RequiredFiles []string
}
EnvironmentRequirements defines environment setup requirements.
type ErrorRule ¶
type ErrorRule struct {
Pattern string // URL pattern to match
ErrorType ErrorType // Type of error to simulate
Probability float64 // Probability of error (0.0 to 1.0)
Delay time.Duration // Delay before error/response
ResponseCode int // HTTP response code for HTTP errors
Message string // Error message
Count int // Number of times to apply this rule (0 = infinite)
// contains filtered or unexported fields
}
ErrorRule defines when and how to simulate network errors.
type ErrorType ¶
type ErrorType int
ErrorType represents different types of network errors.
const ( ErrorTypeTimeout ErrorType = iota // Connection timeout ErrorTypeRefused // Connection refused ErrorType404 // HTTP 404 Not Found ErrorType500 // HTTP 500 Internal Server Error ErrorType503 // HTTP 503 Service Unavailable ErrorTypeSlowResponse // Slow response (high latency) ErrorTypeIncompleteResponse // Connection drops mid-response ErrorTypeDNSFailure // DNS resolution failure )
type ExpectedOutcome ¶
type ExpectedOutcome struct {
ShouldSucceed bool
CurrentBranch string
ConflictsExpected bool
LocalChangesKept bool
RemoteChangesPulled bool
BranchReset bool
}
ExpectedOutcome defines what should happen after applying a strategy.
type FileOperationTest ¶
type FileOperationTest struct {
Name string
Setup func(t *testing.T) string // Returns temp dir path
Execute func(t *testing.T, tempDir string) error
Verify func(t *testing.T, tempDir string, err error)
Cleanup func(t *testing.T, tempDir string)
}
AssertFileOperations provides common file operation test patterns.
type FileRename ¶
FileRename represents a file rename operation.
type GitLFSSimulator ¶
type GitLFSSimulator struct {
// contains filtered or unexported fields
}
GitLFSSimulator simulates Git LFS (Large File Storage) environments for testing synclone behavior with large files and LFS tracking.
func NewGitLFSSimulator ¶
func NewGitLFSSimulator() *GitLFSSimulator
NewGitLFSSimulator creates a new GitLFSSimulator instance
func (*GitLFSSimulator) CreateLFSRepository ¶
func (lfs *GitLFSSimulator) CreateLFSRepository(ctx context.Context, repoPath string, config LFSConfig) error
CreateLFSRepository creates a repository with Git LFS configured
func (*GitLFSSimulator) CreateSimpleLFSRepo ¶
func (lfs *GitLFSSimulator) CreateSimpleLFSRepo(ctx context.Context, repoPath string) error
CreateSimpleLFSRepo creates a simple LFS repository with common patterns
func (*GitLFSSimulator) GetLFSStatus ¶
GetLFSStatus returns the LFS status of the repository
func (*GitLFSSimulator) IsLFSAvailable ¶
func (lfs *GitLFSSimulator) IsLFSAvailable(ctx context.Context) bool
IsLFSAvailable checks if Git LFS is available on the system
type GitOperationSimulator ¶
type GitOperationSimulator struct {
// contains filtered or unexported fields
}
GitOperationSimulator simulates network issues during Git operations.
func NewGitOperationSimulator ¶
func NewGitOperationSimulator() *GitOperationSimulator
NewGitOperationSimulator creates a Git operation simulator.
func (*GitOperationSimulator) Cleanup ¶
func (gos *GitOperationSimulator) Cleanup()
Cleanup stops the test server.
func (*GitOperationSimulator) GetServerURL ¶
func (gos *GitOperationSimulator) GetServerURL() string
GetServerURL returns the URL of the test server.
func (*GitOperationSimulator) SimulateCloneFailure ¶
func (gos *GitOperationSimulator) SimulateCloneFailure(ctx context.Context, failureType string) error
SimulateCloneFailure simulates failures during git clone.
type IntegrationTestHelper ¶
type IntegrationTestHelper struct {
// contains filtered or unexported fields
}
IntegrationTestHelper provides common integration test patterns.
func NewIntegrationTestHelper ¶
func NewIntegrationTestHelper(t *testing.T, skipMessage string) *IntegrationTestHelper
NewIntegrationTestHelper creates a new integration test helper.
func (*IntegrationTestHelper) AssertAPIResponse ¶
func (i *IntegrationTestHelper) AssertAPIResponse(response interface{}, err error)
AssertAPIResponse verifies common API response patterns.
func (*IntegrationTestHelper) SkipIfNeeded ¶
func (i *IntegrationTestHelper) SkipIfNeeded(condition bool)
SkipIfNeeded skips the test if integration conditions are not met.
type LFSConfig ¶
type LFSConfig struct {
TrackPatterns []string // File patterns to track with LFS
LargeFiles []LFSFile // Large files to create and track
Attributes map[string]string // Custom .gitattributes entries
}
LFSConfig represents Git LFS configuration options
type LFSFile ¶
type LFSFile struct {
Path string // File path relative to repo root
SizeMB int64 // Size in megabytes
Content string // Content type: "random", "text", "binary"
Tracked bool // Whether file should be tracked by LFS
}
LFSFile represents a large file managed by LFS
type LFSStatus ¶
type LFSStatus struct {
Available bool // Whether Git LFS is available
Initialized bool // Whether LFS is initialized in the repo
TrackedFiles []string // Files currently tracked by LFS
}
LFSStatus represents the Git LFS status
type LargeRepoCreator ¶
type LargeRepoCreator struct {
// contains filtered or unexported fields
}
LargeRepoCreator creates repositories with large files to test performance and handling of repositories with significant disk usage.
func NewLargeRepoCreator ¶
func NewLargeRepoCreator() *LargeRepoCreator
NewLargeRepoCreator creates a new LargeRepoCreator instance.
func (*LargeRepoCreator) CreateLargeRepo ¶
func (c *LargeRepoCreator) CreateLargeRepo(ctx context.Context, opts LargeRepoOptions) error
CreateLargeRepo creates a repository with large files.
func (*LargeRepoCreator) CreateLargeRepoSimple ¶
func (c *LargeRepoCreator) CreateLargeRepoSimple(ctx context.Context, repoPath string, sizeMB int64) error
CreateLargeRepoSimple creates a simple large repository with default options.
func (*LargeRepoCreator) CreateLargeRepoWithHistory ¶
func (c *LargeRepoCreator) CreateLargeRepoWithHistory(ctx context.Context, repoPath string) error
CreateLargeRepoWithHistory creates a repository with large files and commit history.
func (*LargeRepoCreator) CreateRepoWithBinaryFiles ¶
func (c *LargeRepoCreator) CreateRepoWithBinaryFiles(ctx context.Context, repoPath string) error
CreateRepoWithBinaryFiles creates a repository with various binary file types.
func (*LargeRepoCreator) GetRepoSize ¶
func (c *LargeRepoCreator) GetRepoSize(repoPath string) (int64, error)
GetRepoSize calculates the approximate repository size.
type LargeRepoOptions ¶
type LargeRepoOptions struct {
RepoPath string
LargeFileSize int64 // Size in MB
FileCount int // Number of large files
WithHistory bool // Create commit history with large files
ChunkSize int // Write chunk size in KB (for memory efficiency)
}
LargeRepoOptions defines options for creating large repositories.
type LocalChange ¶
LocalChange represents a local uncommitted change.
type LocalChangesSimulator ¶
type LocalChangesSimulator struct {
// contains filtered or unexported fields
}
LocalChangesSimulator simulates various local working directory states for testing synclone behavior with uncommitted and staged changes.
func NewLocalChangesSimulator ¶
func NewLocalChangesSimulator() *LocalChangesSimulator
NewLocalChangesSimulator creates a new LocalChangesSimulator instance.
func (*LocalChangesSimulator) CreateConflictedWorkingDirectory ¶
func (lcs *LocalChangesSimulator) CreateConflictedWorkingDirectory(ctx context.Context, repoPath string) error
CreateConflictedWorkingDirectory creates a repository with conflicted files.
func (*LocalChangesSimulator) CreateDirtyWorkingDirectory ¶
func (lcs *LocalChangesSimulator) CreateDirtyWorkingDirectory(ctx context.Context, repoPath string) error
CreateDirtyWorkingDirectory creates a repository with various uncommitted changes.
func (*LocalChangesSimulator) CreateMixedStateRepository ¶
func (lcs *LocalChangesSimulator) CreateMixedStateRepository(ctx context.Context, repoPath string) error
CreateMixedStateRepository creates a repository with a combination of different states.
func (*LocalChangesSimulator) CreateWorkingDirectoryState ¶
func (lcs *LocalChangesSimulator) CreateWorkingDirectoryState(ctx context.Context, repoPath string, state WorkingDirectoryState) error
CreateWorkingDirectoryState creates a repository with the specified working directory state.
func (*LocalChangesSimulator) GetWorkingDirectoryStatus ¶
func (lcs *LocalChangesSimulator) GetWorkingDirectoryStatus(ctx context.Context, repoPath string) (WorkingDirectoryStatus, error)
GetWorkingDirectoryStatus returns the current status of the working directory.
type LocalFileChange ¶
type LocalFileChange struct {
FilePath string
Content string
ChangeType ChangeType
IsConflicted bool
}
LocalFileChange represents a change to a local file.
type MergeConfig ¶
type MergeConfig struct {
FromBranch string
ToBranch string
Message string
Strategy string // "merge", "rebase", "squash"
}
MergeConfig defines a merge operation.
type MergeConflictGenerator ¶
type MergeConflictGenerator struct {
// contains filtered or unexported fields
}
MergeConflictGenerator creates repositories with various merge conflict scenarios for testing synclone behavior in complex Git states.
func NewMergeConflictGenerator ¶
func NewMergeConflictGenerator() *MergeConflictGenerator
NewMergeConflictGenerator creates a new MergeConflictGenerator instance.
func (*MergeConflictGenerator) CreateComplexConflict ¶
func (mcg *MergeConflictGenerator) CreateComplexConflict(ctx context.Context, repoPath string) error
CreateComplexConflict creates a complex conflict scenario with multiple types.
func (*MergeConflictGenerator) CreateConflictScenario ¶
func (mcg *MergeConflictGenerator) CreateConflictScenario(ctx context.Context, repoPath string, scenario ConflictScenario) error
CreateConflictScenario creates a repository with the specified conflict scenario.
func (*MergeConflictGenerator) CreateDivergedBranchesConflict ¶
func (mcg *MergeConflictGenerator) CreateDivergedBranchesConflict(ctx context.Context, repoPath string) error
CreateDivergedBranchesConflict creates a scenario where branches have diverged significantly.
func (*MergeConflictGenerator) CreateSimpleContentConflict ¶
func (mcg *MergeConflictGenerator) CreateSimpleContentConflict(ctx context.Context, repoPath string) error
CreateSimpleContentConflict creates a basic content conflict scenario.
func (*MergeConflictGenerator) GetConflictStatus ¶
func (mcg *MergeConflictGenerator) GetConflictStatus(ctx context.Context, repoPath string) (ConflictStatus, error)
GetConflictStatus returns information about current merge conflicts.
type MockRepoFactory ¶
type MockRepoFactory interface {
CreateBasicRepos(ctx context.Context, opts BasicRepoOptions) error
CreateConflictRepos(ctx context.Context, opts ConflictRepoOptions) error
CreateSpecialRepos(ctx context.Context, opts SpecialRepoOptions) error
}
MockRepoFactory provides interface for creating test repositories with various Git states for synclone testing.
func NewMockRepoFactory ¶
func NewMockRepoFactory() MockRepoFactory
NewMockRepoFactory creates a new MockRepoFactory instance.
type MockTestHelper ¶
type MockTestHelper struct {
// contains filtered or unexported fields
}
MockTestHelper provides common mock test patterns.
func NewMockTestHelper ¶
func NewMockTestHelper(t *testing.T) *MockTestHelper
NewMockTestHelper creates a new mock test helper.
func (*MockTestHelper) AssertMockCalled ¶
func (m *MockTestHelper) AssertMockCalled(mockCall interface{}, expectedArgs ...interface{})
AssertMockCalled verifies that a mock was called with expected parameters.
type NetworkErrorSimulator ¶
type NetworkErrorSimulator struct {
// contains filtered or unexported fields
}
NetworkErrorSimulator simulates various network error conditions for testing synclone behavior under network failure scenarios.
func NewNetworkErrorSimulator ¶
func NewNetworkErrorSimulator() *NetworkErrorSimulator
NewNetworkErrorSimulator creates a new NetworkErrorSimulator instance.
func (*NetworkErrorSimulator) AddErrorRule ¶
func (nes *NetworkErrorSimulator) AddErrorRule(rule ErrorRule)
AddErrorRule adds a rule for simulating network errors.
func (*NetworkErrorSimulator) ClearErrorRules ¶
func (nes *NetworkErrorSimulator) ClearErrorRules()
ClearErrorRules removes all error rules.
func (*NetworkErrorSimulator) CreateRecoveryScenario ¶
func (nes *NetworkErrorSimulator) CreateRecoveryScenario(ctx context.Context, initialFailures int) *NetworkErrorSimulator
CreateRecoveryScenario creates a scenario where network recovers after initial failures.
func (*NetworkErrorSimulator) GetRequestStats ¶
func (nes *NetworkErrorSimulator) GetRequestStats() RequestStats
GetRequestStats returns statistics about handled requests.
func (*NetworkErrorSimulator) SimulateGitCloneTimeout ¶
func (nes *NetworkErrorSimulator) SimulateGitCloneTimeout(ctx context.Context) *NetworkErrorSimulator
SimulateGitCloneTimeout simulates timeout during git clone operations.
func (*NetworkErrorSimulator) SimulateHTTPErrors ¶
func (nes *NetworkErrorSimulator) SimulateHTTPErrors(ctx context.Context) *NetworkErrorSimulator
SimulateHTTPErrors simulates various HTTP error responses.
func (*NetworkErrorSimulator) SimulateIntermittentConnection ¶
func (nes *NetworkErrorSimulator) SimulateIntermittentConnection(ctx context.Context, failureRate float64) *NetworkErrorSimulator
SimulateIntermittentConnection simulates intermittent connection issues.
func (*NetworkErrorSimulator) StartServer ¶
func (nes *NetworkErrorSimulator) StartServer() string
StartServer starts the mock server for simulating network conditions.
func (*NetworkErrorSimulator) StopServer ¶
func (nes *NetworkErrorSimulator) StopServer()
StopServer stops the mock server.
type PreMergeAction ¶
type PreMergeAction struct {
Branch string
Action string // "commit", "modify", "delete", "rename"
FilePath string
Content string
CommitMsg string
}
PreMergeAction represents actions to take before creating conflicts.
type RemoteChange ¶
type RemoteChange struct {
Branch string
CommitMessage string
Files map[string]string // filename -> content
DeleteFiles []string
}
RemoteChange represents a change made to the remote repository.
type RequestStats ¶
RequestStats contains statistics about simulated requests.
type SpecialRepoOptions ¶
type SpecialRepoOptions struct {
BaseDir string
RepoName string
SpecialType string // "lfs", "submodule", "large"
Size int64 // for large repos
}
SpecialRepoOptions defines options for creating special scenario repositories.
type StandardRepoCreator ¶
type StandardRepoCreator struct {
// contains filtered or unexported fields
}
StandardRepoCreator creates repositories with standard Git structures including multiple commits, branches, and typical development patterns.
func NewStandardRepoCreator ¶
func NewStandardRepoCreator() *StandardRepoCreator
NewStandardRepoCreator creates a new StandardRepoCreator instance.
func (*StandardRepoCreator) CreateDevelopmentRepo ¶
func (c *StandardRepoCreator) CreateDevelopmentRepo(ctx context.Context, repoPath string) error
CreateDevelopmentRepo creates a repository simulating typical development workflow.
func (*StandardRepoCreator) CreateProjectRepo ¶
func (c *StandardRepoCreator) CreateProjectRepo(ctx context.Context, repoPath string, projectType string) error
CreateProjectRepo creates a repository with project-like structure.
func (*StandardRepoCreator) CreateStandardRepo ¶
func (c *StandardRepoCreator) CreateStandardRepo(ctx context.Context, opts StandardRepoOptions) error
CreateStandardRepo creates a repository with typical development patterns.
type StandardRepoOptions ¶
type StandardRepoOptions struct {
RepoPath string
Branches []string
CommitsCount int
WithTags bool
WithMerges bool
}
StandardRepoOptions defines options for creating standard repositories.
type StrategyTestCase ¶
type StrategyTestCase struct {
Strategy string // "reset", "pull", "fetch", "rebase", "clone"
InitialState BranchState // Initial repository state
RemoteChanges []RemoteChange // Simulated remote changes
LocalChanges []LocalChange // Local uncommitted changes
ExpectedOutcome ExpectedOutcome // What should happen
ValidationChecks []ValidationCheck // Checks to verify the outcome
}
StrategyTestCase represents a test case for a specific synclone strategy.
type SubmoduleConfig ¶
type SubmoduleConfig struct {
Name string // Submodule name
Path string // Path within parent repo
URL string // URL or path to submodule repo
Branch string // Branch to track (optional)
}
SubmoduleConfig represents submodule configuration.
type SubmoduleManager ¶
type SubmoduleManager struct {
// contains filtered or unexported fields
}
SubmoduleManager manages Git submodules for testing complex repository structures.
func NewSubmoduleManager ¶
func NewSubmoduleManager() *SubmoduleManager
NewSubmoduleManager creates a new SubmoduleManager instance.
func (*SubmoduleManager) CreateNestedSubmodules ¶
func (sm *SubmoduleManager) CreateNestedSubmodules(ctx context.Context, basePath string) error
CreateNestedSubmodules creates a repository with nested submodules.
func (*SubmoduleManager) CreateRepositoryWithSubmodules ¶
func (sm *SubmoduleManager) CreateRepositoryWithSubmodules(ctx context.Context, parentPath string, submodules []SubmoduleConfig) error
CreateRepositoryWithSubmodules creates a repository with submodules.
func (*SubmoduleManager) GetSubmoduleStatus ¶
func (sm *SubmoduleManager) GetSubmoduleStatus(ctx context.Context, repoPath string) ([]SubmoduleStatus, error)
GetSubmoduleStatus returns the status of all submodules.
func (*SubmoduleManager) UpdateSubmodules ¶
func (sm *SubmoduleManager) UpdateSubmodules(ctx context.Context, repoPath string) error
UpdateSubmodules updates all submodules to latest commits.
type SubmoduleStatus ¶
type SubmoduleStatus struct {
Name string
Path string
Hash string
Status string // "", "+", "-", "U" for clean, ahead, behind, conflict
}
SubmoduleStatus represents the status of a submodule.
type ValidationCheck ¶
type ValidationCheck struct {
Name string
CheckType string // "file_exists", "file_content", "branch_state", "git_status"
Target string // file path or branch name
Expected string // expected value
Description string
}
ValidationCheck defines a check to validate the outcome.
type WorkingDirectoryState ¶
type WorkingDirectoryState struct {
UncommittedChanges []LocalFileChange
StagedChanges []LocalFileChange
UntrackedFiles []LocalFileChange
DeletedFiles []string
RenamedFiles []FileRename
}
WorkingDirectoryState represents different states of a working directory.
type WorkingDirectoryStatus ¶
type WorkingDirectoryStatus struct {
ModifiedFiles []string
AddedFiles []string
DeletedFiles []string
RenamedFiles []string
UntrackedFiles []string
ConflictedFiles []string
}
WorkingDirectoryStatus represents the parsed status of a working directory.
func (WorkingDirectoryStatus) HasConflicts ¶
func (wds WorkingDirectoryStatus) HasConflicts() bool
HasConflicts returns true if there are conflicted files.
func (WorkingDirectoryStatus) HasUncommittedChanges ¶
func (wds WorkingDirectoryStatus) HasUncommittedChanges() bool
HasUncommittedChanges returns true if there are uncommitted changes.
func (WorkingDirectoryStatus) IsClean ¶
func (wds WorkingDirectoryStatus) IsClean() bool
IsClean returns true if the working directory has no changes.
Source Files
¶
- basic_repo_creator.go
- branch_manager.go
- branch_strategy_tester.go
- devenv_test_helpers.go
- e2e_test_helpers.go
- git_lfs_simulator.go
- github_test_helpers.go
- large_repo_creator.go
- local_changes_simulator.go
- merge_conflict_generator.go
- mock_repo_factory.go
- network_error_simulator.go
- standard_repo_creator.go
- submodule_manager.go