Tests
Comprehensive integration test suite for VersionControlManager class.
This module contains end-to-end integration tests for the VersionControlManager class, testing the complete semantic versioning workflow using a real Git repository. Unlike unit tests that mock Git operations, these tests create actual commits and tags to verify the complete functionality in a realistic environment.
Test Strategy
- Uses a real Git repository ('test_dir') for authentic testing
- Creates actual commits and tags to simulate real development workflow
- Tests complete semantic versioning lifecycle from development to production
- Validates error handling and business rule enforcement
- Covers edge cases and version bump scenarios
Workflow Coverage
- Development tag creation and incrementing (X.Y.Z-dev.N)
- Release candidate initialization and management (X.Y.Z-rc.N)
- Production tag creation from RC tags (X.Y.Z)
- Patch tag workflow for hotfixes (X.Y.Z-patch.N)
- Version bumping (minor and major)
- Error conditions and validation rules
Dependencies
- pytest: Testing framework for assertions and exception handling
- GitPython: Real Git operations (not mocked)
- os, sys, shutil: File system operations for test cleanup
Test Environment
- Creates temporary 'test_dir' Git repository
- Automatically cleans up test repository after completion
- Uses sequential test execution that builds upon previous states
Author: Sajin Vachery
InvalidTagCreation
Bases: Exception
Custom exception raised when attempting to create an invalid Git tag.
This exception is used to prevent the creation of tags that would violate the versioning rules enforced by the VersionControlManager class.
Source code in src/exceptions.py
1 2 3 4 5 6 7 8 9 |
|
VersionControlManager
A manager class for handling Git tags with semantic versioning.
This class provides functionality to create, manage, and increment Git tags following semantic versioning patterns. It supports development, release candidate, patch, and production tags with proper validation and incrementing logic.
Attributes:
Name | Type | Description |
---|---|---|
repo |
Repo
|
The GitPython repository object for the managed repository. |
Source code in src/vcm.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
__init__(repo_path)
Initialize the VersionControlManager with a repository path.
If the repository doesn't exist at the given path, it will be created and initialized as a new Git repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_path
|
str
|
The file system path to the Git repository. |
required |
Source code in src/vcm.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
create_prod_tag(tag)
Create a production tag from a release candidate or patch prerelease.
Converts an RC or patch prerelease tag into a production version tag. For RC tags, creates the base version (X.Y.Z). For patch tags, creates the next patch version (X.Y.Z+1).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
The RC or patch prerelease tag to promote to production. Format: "X.Y.Z-rc.N" or "X.Y.Z-patch.N". |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The newly created production tag. |
Raises:
Type | Description |
---|---|
ValueError
|
If the tag doesn't match the expected RC or patch pattern. |
Source code in src/vcm.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
find_tag(tag)
Check if a specific tag exists in the repository.
Performs an exact match search for the given tag name in the repository's tag collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
The exact tag name to search for. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the tag exists, False otherwise. |
Source code in src/vcm.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
find_tag_with_pattern(pattern)
Find the highest semantic version tag matching a regex pattern.
Searches through all repository tags for those matching the given regex pattern, then returns the highest version according to semantic versioning rules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern
|
str
|
Regular expression pattern to match against tag names. |
required |
Returns:
Type | Description |
---|---|
str or None: The highest semantic version tag matching the pattern, or None if no matching tags are found. |
Source code in src/vcm.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
get_current_rc_patch(tag, prerelease_tag='rc')
Get the current highest RC or patch tag for a given base version.
Finds the highest prerelease tag (rc or patch) that corresponds to the given base production version tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
Base production version tag in format "X.Y.Z". |
required |
prerelease_tag
|
str
|
The prerelease type ("rc" or "patch"). Defaults to "rc". |
'rc'
|
Returns:
Type | Description |
---|---|
str or None: The highest matching prerelease tag, or None if none exist. |
Raises:
Type | Description |
---|---|
ValueError
|
If the base tag doesn't match the production version pattern. |
Source code in src/vcm.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
get_current_tag(prerelease_tag='dev', production=False)
Get the current highest tag for a specific type (prerelease or production).
Retrieves the highest semantic version tag of either production format (X.Y.Z) or prerelease format (X.Y.Z-prerelease.N) based on the parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prerelease_tag
|
str
|
The prerelease identifier (e.g., "dev", "rc"). Defaults to "dev". |
'dev'
|
production
|
bool
|
If True, searches for production tags (X.Y.Z format). If False, searches for prerelease tags. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
str or None: The highest matching tag, or None if no matching tags exist. |
Source code in src/vcm.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
get_init_rc_tag(tag)
staticmethod
Generate an initial release candidate tag from a prerelease tag.
Takes a prerelease tag (e.g., "1.2.3-dev.4") and converts it to an initial release candidate tag (e.g., "1.2.3-rc.1").
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
A prerelease tag in the format "X.Y.Z-prerelease.N" |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The corresponding initial RC tag in format "X.Y.Z-rc.1" |
Raises:
Type | Description |
---|---|
ValueError
|
If the tag doesn't match the expected prerelease pattern. |
Source code in src/vcm.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
increment_prerelease_tag(tag=None, prerelease_tag='dev', major_bump=False)
Create and increment a prerelease tag.
Creates a new prerelease tag by either incrementing an existing tag or starting a new version sequence. Handles major/minor version bumps when transitioning from one prerelease to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
Base tag to increment from. If None, starts with "0.1.0-dev.1". |
None
|
prerelease_tag
|
str
|
The prerelease identifier. Defaults to "dev". |
'dev'
|
major_bump
|
bool
|
If True, performs a major version bump instead of minor. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
The newly created prerelease tag. |
Raises:
Type | Description |
---|---|
ValueError
|
If the provided tag doesn't match the expected prerelease pattern. |
Source code in src/vcm.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
increment_rc_patch(tag, prerelease_tag='rc')
Increment a release candidate or patch prerelease tag.
Creates the next RC or patch prerelease tag for a given base version. Includes validation to ensure proper versioning rules are followed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
Base production version tag in format "X.Y.Z". |
required |
prerelease_tag
|
str
|
The prerelease type ("rc" or "patch"). Defaults to "rc". |
'rc'
|
Returns:
Type | Description |
---|---|
str or None: The newly created incremented tag, or None if no base prerelease tag exists to increment. |
Raises:
Type | Description |
---|---|
ValueError
|
If the base tag doesn't match the production version pattern. |
InvalidTagCreation
|
If attempting to create an RC when production version exists, or attempting to create a patch when production version doesn't exist, or when a patch already exists in production. |
Source code in src/vcm.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
init_new_patch()
Initialize a new patch prerelease from the current production tag.
Creates the first patch prerelease tag (X.Y.Z-patch.1) based on the highest existing production tag. The patch tag points to the same commit as the production tag.
Returns:
Type | Description |
---|---|
str or None: The newly created patch tag name, or None if no production tag exists to base the patch on. |
Source code in src/vcm.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
init_new_rc(prerelease_tag='dev')
Initialize a new release candidate from the current development tag.
Creates the first release candidate tag (X.Y.Z-rc.1) based on the highest existing development tag. The RC tag points to the same commit as the dev tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prerelease_tag
|
str
|
The development prerelease identifier. Defaults to "dev". |
'dev'
|
Returns:
Type | Description |
---|---|
str or None: The newly created RC tag name, or None if no development tag exists to base the RC on. |
Source code in src/vcm.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
create_tag(tag)
Create a specific tag in the test repository.
This utility function creates a Git tag with the given name in the test repository. It's used to set up test scenarios that require specific tags to exist before testing VersionControlManager functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
The tag name to create (should follow semantic versioning) |
required |
Side Effects
- Creates a new Git tag in the test repository
- Tag points to the current HEAD commit
Note
This function bypasses VersionControlManager's validation and directly creates tags via GitPython, allowing test setup that might not be possible through the manager's normal workflow.
Source code in tests/test_vcm.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
create_tags()
Create a sequence of development tags for testing.
This setup function creates a series of development tags (1.0.0-dev.0 through 1.0.0-dev.9) with corresponding commits. This simulates a development workflow where multiple development iterations have occurred.
The function creates both commits and tags to establish a realistic repository state for testing tag management operations.
Side Effects
- Creates 10 empty commits in the repository
- Creates 10 development tags pointing to these commits
- Establishes a baseline for subsequent tag operations
Usage
Typically called once during test setup to create a repository state that allows testing of tag incrementing, RC creation, and other advanced operations.
Source code in tests/test_vcm.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
empty_commit()
Create an empty commit in the test repository.
This utility function creates a commit in the test repository without adding any files. It's used to advance the commit history so that new tags can be created at different commit points, simulating real development progress.
The function operates on the global 'test_dir' repository and is essential for tag creation since Git requires commits to exist before tags can be created.
Side Effects
- Creates a new commit in the test repository
- Advances the repository's commit history
- Enables subsequent tag creation
Source code in tests/test_vcm.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
test_complete_multi_version_workflow()
Test complete multi-version development workflow.
This comprehensive test simulates a realistic multi-version development scenario with overlapping releases, patches, and development cycles. It validates the complete system behavior over an extended period.
Test Workflow
- Complete 2.1.0 release cycle (RC → production)
- Start 2.2.0 development with minor bump
- Create patch for 2.1.0 while 2.2.0 development continues
- Start major 3.0.0 development cycle
- Validate all version families coexist correctly
Validates
- Multi-version workflow management
- Version family independence
- Concurrent development and patch workflows
- Long-term version history integrity
- Complex version state management
Business Logic Tested
- Complete workflow cycles across multiple versions
- Version family separation and coexistence
- Long-term tag management and retrieval
- Complex version state scenarios
Source code in tests/test_vcm.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
test_create_prod_from_patch()
Test production tag creation from patch prerelease.
This test verifies the VersionControlManager's ability to promote a tested patch prerelease to a production patch version. This completes the hotfix workflow by creating an official patch release.
Test Scenario
- Promote patch "1.0.0-patch.2" to production "1.0.1"
Validates
- Patch to production tag conversion
- Automatic patch number increment (1.0.0 → 1.0.1)
- Hotfix workflow completion
- Production tag creation with proper commit reference
Business Logic Tested
- create_prod_tag() method with patch prerelease parameter
- Patch version incrementing rules
- Production tag naming for patches
- Hotfix to production workflow transition
Workflow Context
This represents the completion of a hotfix cycle where a thoroughly tested patch is promoted to production, creating an official patch release (1.0.1) that fixes issues in 1.0.0.
Source code in tests/test_vcm.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
test_current_tag()
Test current tag retrieval functionality.
This test verifies the VersionControlManager's ability to identify and return the current highest development tag. It tests both empty repository scenarios and repositories with multiple development tags.
Test Scenario
- Start with empty repository (should return None)
- Create first development tag and verify retrieval
- Create multiple development tags and verify highest is returned
Validates
- Empty repository handling (returns None)
- Initial tag creation (0.1.0-dev.1)
- Highest tag identification from multiple options
- Semantic version sorting (1.0.0-dev.9 > 0.1.0-dev.1)
Business Logic Tested
- get_current_tag() with default "dev" prerelease identifier
- increment_prerelease_tag() initial tag creation
- Proper semantic version comparison and sorting
Source code in tests/test_vcm.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
test_edge_cases_and_boundaries()
Test edge cases and boundary conditions.
This test covers various edge cases that might occur in real-world usage, ensuring the VersionControlManager is robust and handles unusual but valid scenarios correctly.
Test Scenarios
- Version number boundaries (0.0.0, high numbers)
- Empty repository initialization
- Tag creation from initial state
- Pattern matching edge cases
Validates
- Robustness with edge case version numbers
- Proper handling of empty repository states
- Initial tag creation workflows
- Pattern matching accuracy with various formats
Business Logic Tested
- Version number parsing and validation
- Initial state handling
- Pattern matching reliability
- Boundary condition handling
Source code in tests/test_vcm.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
|
test_find_tag()
Test tag existence checking functionality.
This test verifies the VersionControlManager's ability to check whether specific tags exist in the repository. It tests both positive (tag exists) and negative (tag doesn't exist) cases.
Test Scenarios
- Search for non-existent tag (should return False)
- Search for existing tag (should return True)
Validates
- Accurate tag existence detection
- Case-sensitive tag name matching
- Repository tag collection querying
Business Logic Tested
- find_tag() method with exact tag name matching
- Repository tag enumeration and comparison
- Boolean return values for existence checks
Source code in tests/test_vcm.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
test_get_current_patch()
Test patch tag retrieval for versions without patches.
This test verifies that the VersionControlManager correctly handles queries for patch tags when no patch versions exist. This establishes the baseline before patch tag creation and tests proper None handling.
Test Scenarios
- Query patch for version "1.0.0" (production exists, no patches)
- Query patch for version "1.1.0" (no production, no patches)
Both should return None since no patch tags exist yet.
Validates
- Proper None return for non-existent patch tags
- Patch tag querying for different version states
- Baseline establishment for patch workflow testing
Business Logic Tested
- get_current_rc_patch() method with "patch" prerelease type
- Pattern matching for patch tags
- Handling of non-existent tag scenarios
Source code in tests/test_vcm.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
test_get_current_production_tag()
Test current production tag retrieval.
This test verifies the VersionControlManager's ability to identify and return the current highest production version. This is essential for various operations including patch initialization and version management.
Test Scenario
- Retrieve current production tag (should be "1.0.1" after patch)
Validates
- Production tag identification
- Highest production version selection
- Patch version recognition as production
- Production tag querying functionality
Business Logic Tested
- get_current_tag() method with production=True parameter
- Production tag pattern matching
- Semantic version sorting for production tags
- Production version history tracking
Workflow Context
After creating patch version 1.0.1, it should be recognized as the current production version, taking precedence over 1.0.0.
Source code in tests/test_vcm.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
test_get_current_rc()
Test current release candidate retrieval for specific version.
This test verifies the VersionControlManager's ability to find the current (highest) release candidate tag for a specific base version. This is essential for RC management and incrementing operations.
Test Scenario
- Retrieve current RC for base version "1.0.0"
- Should return "1.0.0-rc.1" (the existing RC tag)
Validates
- Base version to RC tag mapping
- Current RC identification for specific versions
- Proper pattern matching for RC tags
Business Logic Tested
- get_current_rc_patch() method with RC prerelease type
- Version-specific tag pattern matching
- Highest RC tag identification within version family
Source code in tests/test_vcm.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
test_get_init_rc_tag()
Test release candidate tag generation from development tags.
This test verifies the static utility method that converts development tags into their corresponding initial release candidate tags. This is a crucial step in the development → RC → production workflow.
Test Scenario
- Convert development tag "1.0.0-dev.10" to RC tag "1.0.0-rc.1"
Validates
- Proper tag format conversion (dev.N → rc.1)
- Preservation of major.minor.patch version
- Static method functionality (no repository interaction)
- Semantic versioning rule compliance
Business Logic Tested
- get_init_rc_tag() static method
- Development to RC tag transformation logic
- Version number parsing and reconstruction
Source code in tests/test_vcm.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
test_increment_dev_after_prod_release()
Test development tag incrementing after production release.
This test verifies the VersionControlManager's ability to continue development work after a production release by automatically bumping to the next minor version for new development work. This ensures clear separation between released and unreleased code.
Test Scenario
- Current dev tag is "1.0.0-dev.10" (same version as production "1.0.0")
- Incrementing should jump to "1.1.0-dev.1" (next minor version)
Validates
- Automatic minor version bump when production version exists
- Prevention of dev tag confusion with released versions
- Proper version increment logic (1.0.x → 1.1.0)
- Development workflow continuation after release
Business Logic Tested
- increment_prerelease_tag() version bump logic
- Production version conflict detection
- Minor version incrementing rules
- Development tag reset to .1 after version bump
Workflow Context
This simulates the common scenario where development continues after a release, requiring a clear version separation between the released code and new development work.
Source code in tests/test_vcm.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
test_increment_patch()
Test patch tag incrementing during hotfix development.
This test verifies the VersionControlManager's ability to increment patch prerelease tags during hotfix development iterations. This allows multiple rounds of fixes and testing before the hotfix is released.
Test Scenario
- Increment patch from "1.0.0-patch.1" to "1.0.0-patch.2"
Validates
- Patch prerelease number incrementing (patch.1 → patch.2)
- Preservation of base production version (1.0.0)
- Hotfix iteration support
- Tag creation in repository
Business Logic Tested
- increment_rc_patch() method with patch prerelease type
- Patch tag incrementing logic
- Hotfix development workflow support
- Prerelease number management for patches
Workflow Context
This simulates additional iterations in hotfix development, where multiple patch versions might be needed before the fix is ready for production deployment.
Source code in tests/test_vcm.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
test_increment_patch_exception()
Test error handling for invalid patch increment attempts.
This test verifies that the VersionControlManager enforces the business rule that patch tags can only be created for versions that have been released to production. This prevents patch creation for unreleased versions, maintaining version integrity.
Test Scenario
- Attempt to create patch for version "1.1.0" (no production version)
- Should raise InvalidTagCreation exception
Validates
- Business rule enforcement (patches require production version)
- Proper exception raising for invalid operations
- Production version prerequisite checking
- Error message clarity for debugging
Business Logic Tested
- increment_rc_patch() validation with patch type
- InvalidTagCreation exception for rule violations
- Production version existence validation
- Patch creation prerequisites
Error Scenario
Documents the rule: "No Production version available" - patches can only be created for versions that have been officially released.
Source code in tests/test_vcm.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
test_increment_prerelease_tag()
Test prerelease tag incrementing functionality.
This test verifies that the VersionControlManager can correctly increment the prerelease number of an existing development tag while maintaining the same major.minor.patch version numbers.
Test Scenario
- Increment from existing tag "1.0.0-dev.9" to "1.0.0-dev.10"
- Verify the new tag becomes the current highest tag
Validates
- Prerelease number incrementing (9 → 10)
- Tag creation in repository
- Updated current tag retrieval
- Preservation of major.minor.patch version
Business Logic Tested
- increment_prerelease_tag() with existing tag parameter
- Proper prerelease number parsing and incrementing
- Tag creation and registration in repository
Source code in tests/test_vcm.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
test_increment_rc()
Test release candidate tag incrementing.
This test verifies the VersionControlManager's ability to create subsequent release candidate versions when additional RC iterations are needed during the testing and stabilization phase.
Test Scenario
- Increment RC from "1.0.0-rc.1" to "1.0.0-rc.2"
- Verify new RC becomes the current RC for the version
Validates
- RC prerelease number incrementing (rc.1 → rc.2)
- Preservation of base version (1.0.0)
- Tag creation in repository
- Updated current RC retrieval
Business Logic Tested
- increment_rc_patch() method with RC prerelease type
- RC tag incrementing logic
- Current RC tag updating after increment
Workflow Context
This simulates the scenario where an RC needs additional iterations due to bugs found during testing, requiring RC.2, RC.3, etc.
Source code in tests/test_vcm.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
test_increment_rc_exception()
Test error handling for invalid RC increment attempts.
This test verifies that the VersionControlManager properly enforces business rules by preventing RC tag creation when a production version already exists for the same version number. This prevents accidental regression or confusion in the versioning workflow.
Test Scenario
- Attempt to increment RC for version "1.0.0" (production exists)
- Should raise InvalidTagCreation exception
Validates
- Business rule enforcement (no RC after production)
- Proper exception raising and type
- Error message clarity and helpfulness
- Repository state validation before tag creation
Business Logic Tested
- increment_rc_patch() validation logic
- InvalidTagCreation exception handling
- Production version existence checking
- Business rule compliance enforcement
Error Scenario
This test documents the rule: "Cannot increment RC version for a version found in Production" - once a version goes to production, no more RCs can be created for that version.
Source code in tests/test_vcm.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
test_init_new_patch()
Test patch tag initialization for hotfix workflow.
This test verifies the VersionControlManager's ability to initialize the patch workflow for production hotfixes. This creates the first patch prerelease tag based on the current production version, enabling hotfix development.
Test Scenario
- Initialize patch from current production (should be "1.0.0")
- Should create "1.0.0-patch.1" for hotfix development
Validates
- Patch initialization from production version
- Proper patch tag naming (version-patch.1)
- Hotfix workflow establishment
- Current production version detection
Business Logic Tested
- init_new_patch() method
- Production to patch workflow transition
- Patch tag creation with proper commit reference
- Hotfix development setup
Workflow Context
This represents the beginning of a hotfix process where a critical bug in production needs to be addressed without waiting for the next major release cycle.
Source code in tests/test_vcm.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
test_init_new_rc()
Test release candidate initialization from current development tag.
This test verifies the VersionControlManager's ability to create the first release candidate tag based on the highest existing development tag. This represents a key milestone in the development workflow where development is considered feature-complete and ready for testing.
Test Scenario
- Initialize RC from current development tag (1.0.0-dev.10)
- Verify RC tag creation (1.0.0-rc.1)
- Confirm RC becomes current RC tag
Validates
- RC initialization from development tag
- Proper RC tag naming (major.minor.patch-rc.1)
- Tag creation in repository with appropriate commit reference
- Current RC tag retrieval functionality
Business Logic Tested
- init_new_rc() method with development prerelease parameter
- Development to RC workflow transition
- Tag creation with commit referencing
- RC tag identification and retrieval
Source code in tests/test_vcm.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
test_invalid_tag_format_handling()
Test handling of invalid tag formats and edge cases.
This test validates that the VersionControlManager properly handles and rejects invalid tag formats, maintaining system integrity and providing clear error messages.
Test Scenarios
- Invalid prerelease tag formats
- Invalid production tag formats
- Malformed version numbers
- Edge case version patterns
Validates
- Proper ValueError raising for invalid formats
- Input validation before tag operations
- Error message clarity and helpfulness
- System protection against malformed inputs
Business Logic Tested
- Tag format validation across all methods
- ValueError exception handling
- Input sanitization and validation
- Format compliance enforcement
Source code in tests/test_vcm.py
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
|
test_major_bump()
Test complete major version bump workflow.
This comprehensive test verifies the VersionControlManager's ability to handle a complete major version bump scenario, simulating a development cycle that includes breaking changes requiring a major version increment.
Test Workflow
- Start with current dev tag "1.1.0-dev.1"
- Increment to "1.1.0-dev.2" (normal development)
- Create RC "1.1.0-rc.1" and promote to production "1.1.0"
- Perform major bump to "2.0.0-dev.1" (breaking changes)
- Verify new major version becomes current
Validates
- Complete development cycle (dev → RC → production)
- Major version bumping logic (1.x.x → 2.0.0)
- Version reset behavior (minor and patch reset to 0)
- Development tag reset to .1 after major bump
- Production version progression (1.0.1 → 1.1.0 → current)
Business Logic Tested
- increment_prerelease_tag() normal and major bump modes
- init_new_rc() and create_prod_tag() workflow
- Major version bump with major_bump=True parameter
- Version number reset rules for major bumps
- Current tag tracking across version families
Workflow Context
This simulates a complete development cycle where significant breaking changes necessitate a major version increment, following semantic versioning principles where major bumps indicate backward-incompatible changes.
Source code in tests/test_vcm.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
|
test_multiple_rc_iterations()
Test multiple release candidate iterations before production.
This test simulates a realistic scenario where multiple RC versions are needed due to bugs found during testing. It validates the complete RC iteration workflow and proper version incrementing.
Test Workflow
- Create multiple RC iterations (rc.1 → rc.2 → rc.3)
- Verify each increment is properly tracked
- Promote final RC to production
- Verify production version is correct
Validates
- Multiple RC increments within same version
- RC version tracking and retrieval
- Final RC promotion to production
- Version consistency throughout process
Business Logic Tested
- increment_rc_patch() multiple iterations
- get_current_rc_patch() after each increment
- create_prod_tag() from any RC iteration
- RC workflow resilience with multiple iterations
Source code in tests/test_vcm.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
test_parallel_development_after_release()
Test parallel development workflow after production release.
This test simulates a realistic scenario where development continues in parallel with production releases and hotfixes. It validates that development can proceed independently while production versions are being patched.
Test Workflow
- Continue development after 2.0.0 release (should bump to 2.1.0-dev.1)
- Create multiple development iterations
- While dev continues, ensure patch workflow still works
- Create RC from latest development
- Validate version separation and independence
Validates
- Development continuation after production release
- Proper minor version bump for new development
- Independence of dev and patch workflows
- Version family separation (2.0.x patches vs 2.1.x development)
- Multiple concurrent version tracks
Business Logic Tested
- increment_prerelease_tag() with automatic version bump detection
- Parallel workflow support (dev vs patch)
- Version family isolation
- Current tag tracking across different version families
Source code in tests/test_vcm.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
|
test_patch_workflow_comprehensive()
Test comprehensive patch workflow with multiple iterations.
This test validates the complete patch/hotfix workflow including multiple patch iterations, proper version incrementing, and integration with the existing production version history.
Test Workflow
- Create initial patch from production 2.0.0
- Increment patch multiple times (simulating hotfix development)
- Promote patch to production (creates 2.0.1)
- Create another patch series for 2.0.1
- Validate version progression and current version tracking
Validates
- Patch initialization from any production version
- Multiple patch increments within same base version
- Patch promotion creating proper production increment
- Ability to patch the patched version
- Production version progression (2.0.0 → 2.0.1 → 2.0.2)
Business Logic Tested
- init_new_patch() from latest production
- increment_rc_patch() with patch type multiple times
- create_prod_tag() from patch creating incremented production
- Patch workflow on previously patched versions
Source code in tests/test_vcm.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
|
test_prod_release()
Test production tag creation from release candidate.
This test verifies the final step in the development workflow: promoting a tested and approved release candidate to a production version. This represents the official release of the software version.
Test Scenario
- Promote RC tag "1.0.0-rc.2" to production tag "1.0.0"
Validates
- RC to production tag conversion
- Removal of prerelease suffix (-rc.2 → "")
- Tag creation with proper commit reference
- Production tag format compliance
Business Logic Tested
- create_prod_tag() method with RC tag parameter
- RC to production workflow transition
- Production tag naming rules
- Commit reference preservation during promotion
Workflow Context
This represents the culmination of the development cycle where a thoroughly tested RC is deemed ready for production deployment.
Source code in tests/test_vcm.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
test_repository_state_integrity()
Test repository state integrity throughout complex operations.
This test validates that the VersionControlManager maintains repository integrity and consistency throughout complex operation sequences. It ensures no orphaned tags or inconsistent states are created.
Test Scenarios
- Verify all created tags exist in repository
- Validate tag-commit relationships
- Check version history consistency
- Ensure no duplicate or conflicting tags
Validates
- Repository tag integrity
- Consistent tag-commit relationships
- Version history accuracy
- No duplicate or orphaned tags
Business Logic Tested
- find_tag() accuracy for all created tags
- Repository state consistency
- Tag creation integrity
- Version tracking accuracy
Source code in tests/test_vcm.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
|
test_version_conflict_prevention()
Test version conflict prevention and validation rules.
This test validates all the business rules that prevent invalid version states and conflicts in the semantic versioning workflow. It ensures proper error handling and validation.
Test Scenarios
- Try to create RC when production already exists
- Try to create patch when no production exists
- Try to increment patch when higher patch exists in production
- Validate proper exception messages and types
Validates
- Business rule enforcement prevents invalid states
- Proper exception types (InvalidTagCreation)
- Clear error messages for debugging
- Version state validation before tag creation
Business Logic Tested
- increment_rc_patch() validation rules
- InvalidTagCreation exception handling
- Production version conflict detection
- Patch prerequisite validation
Source code in tests/test_vcm.py
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|