diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-04-13 23:14:56 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-04-15 08:36:03 +0200 |
commit | a304fed68cd2208c3e78afd9ea99446d5b5f4444 (patch) | |
tree | ee3068f3dad9931a38f519aa26d5db7c6ce9ccaa /pkg/integration/components/test_test.go | |
parent | 227b0b781cb4aab2ae613a66f2e73467670ae208 (diff) |
Add GitVersion field to NewIntegrationTestArgs
It can be used to specify which git versions a given test should or should not run on.
Diffstat (limited to 'pkg/integration/components/test_test.go')
-rw-r--r-- | pkg/integration/components/test_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index 4216b8130..062382c2d 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -87,3 +88,65 @@ func TestSuccess(t *testing.T) { assert.EqualValues(t, []string{"a", "b"}, driver.pressedKeys) assert.Equal(t, "", driver.failureMessage) } + +func TestGitVersionRestriction(t *testing.T) { + scenarios := []struct { + testName string + gitVersion GitVersionRestriction + expectedShouldRun bool + }{ + { + testName: "From, current is newer", + gitVersion: From("2.24.9"), + expectedShouldRun: true, + }, + { + testName: "From, current is same", + gitVersion: From("2.25.0"), + expectedShouldRun: true, + }, + { + testName: "From, current is older", + gitVersion: From("2.26.0"), + expectedShouldRun: false, + }, + { + testName: "Before, current is older", + gitVersion: Before("2.24.9"), + expectedShouldRun: false, + }, + { + testName: "Before, current is same", + gitVersion: Before("2.25.0"), + expectedShouldRun: false, + }, + { + testName: "Before, current is newer", + gitVersion: Before("2.26.0"), + expectedShouldRun: true, + }, + { + testName: "Includes, current is included", + gitVersion: Includes("2.23.0", "2.25.0"), + expectedShouldRun: true, + }, + { + testName: "Includes, current is not included", + gitVersion: Includes("2.23.0", "2.27.0"), + expectedShouldRun: false, + }, + } + + currentGitVersion := git_commands.GitVersion{Major: 2, Minor: 25, Patch: 0} + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + test := NewIntegrationTest(NewIntegrationTestArgs{ + Description: unitTestDescription, + GitVersion: s.gitVersion, + }) + shouldRun := test.ShouldRunForGitVersion(¤tGitVersion) + assert.Equal(t, shouldRun, s.expectedShouldRun) + }) + } +} |