Skip to content
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

tfversion: Treat Terraform CLI prerelease versions as equal to patch versions in SkipBelow #316

Merged
merged 1 commit into from
Mar 28, 2024

Commits on Mar 27, 2024

  1. tfversion: Treat Terraform CLI prerelease versions as equal to patch …

    …versions in SkipBelow
    
    Reference: #303
    Reference: #308
    
    This change is mainly due to the internals of how github.com/hashicorp/go-version treats version comparisons when there is prerelease data. When the running Terraform CLI is a prerelease version and the given version is a patch version, `SkipBelow` will currently skip the test. However, Terraform CLI prerelease versions are semantically treated as candidates for the associated patch version and therefore should be tested. This adjusts `SkipBelow` for that intended behavior. In the unexpected use case that prerelease version checking is still needed, callers can (still) opt into giving a prerelease version, which will perform the check including prerelease data.
    
    The unit testing for the `tfversion` package skip functionality is still manual because `github.com/mitchellh/go-testing-interface` will not immediately stop the test logic Goroutine when the equivalent of `(*testing.T).Skip()` is called nor does it provide helpful troubleshooting information should a test fail as it raises a panic with a generic error message. Future changes could switch to using a different testing interface, however they would require a breaking change to the exported API of this Go module, so that design and effort is being done separately.
    
    With the addition of the new tests, but no logic changes:
    
    ```
    === RUN   Test_SkipBelow_SkipTest
        skip_below_test.go:23: Terraform CLI version 1.0.7 is below minimum version 1.1.0: skipping test
    --- SKIP: Test_SkipBelow_SkipTest (3.91s)
    === RUN   Test_SkipBelow_RunTest
    --- PASS: Test_SkipBelow_RunTest (3.32s)
    === RUN   Test_SkipBelow_Prerelease_EqualCoreVersion
        skip_below_test.go:77: Terraform CLI version 1.8.0-rc1 is below minimum version 1.8.0: skipping test
    --- SKIP: Test_SkipBelow_Prerelease_EqualCoreVersion (4.23s)
    === RUN   Test_SkipBelow_Prerelease_HigherCoreVersion
        skip_below_test.go:101: Terraform CLI version 1.7.0-rc1 is below minimum version 1.8.0: skipping test
    --- SKIP: Test_SkipBelow_Prerelease_HigherCoreVersion (4.40s)
    === RUN   Test_SkipBelow_Prerelease_HigherPrerelease
        skip_below_test.go:122: Terraform CLI version 1.7.0-rc1 is below minimum version 1.7.0-rc2: skipping test
    --- SKIP: Test_SkipBelow_Prerelease_HigherPrerelease (3.32s)
    === RUN   Test_SkipBelow_Prerelease_LowerCoreVersion
    --- PASS: Test_SkipBelow_Prerelease_LowerCoreVersion (3.93s)
    === RUN   Test_SkipBelow_Prerelease_LowerPrerelease
    --- PASS: Test_SkipBelow_Prerelease_LowerPrerelease (3.38s)
    ```
    
    After logic changes (note only difference is `Test_SkipBelow_Prerelease_EqualCoreVersion`):
    
    ```
    === RUN   Test_SkipBelow_SkipTest
        skip_below_test.go:22: Terraform CLI version 1.0.7 is below minimum version 1.1.0: skipping test
    --- SKIP: Test_SkipBelow_SkipTest (4.17s)
    === RUN   Test_SkipBelow_RunTest
    --- PASS: Test_SkipBelow_RunTest (3.21s)
    === RUN   Test_SkipBelow_Prerelease_EqualCoreVersion
    --- PASS: Test_SkipBelow_Prerelease_EqualCoreVersion (3.21s)
    === RUN   Test_SkipBelow_Prerelease_HigherCoreVersion
        skip_below_test.go:99: Terraform CLI version 1.7.0-rc1 is below minimum version 1.8.0: skipping test
    --- SKIP: Test_SkipBelow_Prerelease_HigherCoreVersion (3.18s)
    === RUN   Test_SkipBelow_Prerelease_HigherPrerelease
        skip_below_test.go:120: Terraform CLI version 1.7.0-rc1 is below minimum version 1.7.0-rc2: skipping test
    --- SKIP: Test_SkipBelow_Prerelease_HigherPrerelease (3.21s)
    === RUN   Test_SkipBelow_Prerelease_LowerCoreVersion
    --- PASS: Test_SkipBelow_Prerelease_LowerCoreVersion (3.04s)
    === RUN   Test_SkipBelow_Prerelease_LowerPrerelease
    --- PASS: Test_SkipBelow_Prerelease_LowerPrerelease (3.41s)
    ```
    bflad committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    a0afa02 View commit details
    Browse the repository at this point in the history