-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable auto-merge if the new version has the same prefix with t…
…he old version
- Loading branch information
1 parent
187dcd6
commit 00ed0ff
Showing
4 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package controller | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_compareVersion(t *testing.T) { | ||
t.Parallel() | ||
data := []struct { | ||
name string | ||
currentVersion string | ||
newVersion string | ||
f bool | ||
isErr bool | ||
}{ | ||
{ | ||
name: "normal", | ||
currentVersion: "v2.0.0", | ||
newVersion: "v2.1.0", | ||
f: true, | ||
}, | ||
{ | ||
name: "old", | ||
currentVersion: "v2.1.0", | ||
newVersion: "v2.0.0", | ||
}, | ||
{ | ||
name: "different prefix", | ||
currentVersion: "edge-v2.0.0", | ||
newVersion: "stable-v2.1.0", | ||
}, | ||
{ | ||
name: "same prefix", | ||
currentVersion: "cli-v2.0.0", | ||
newVersion: "cli-v2.1.0", | ||
f: true, | ||
}, | ||
{ | ||
name: "same prefix but old", | ||
currentVersion: "cli-v2.1.0", | ||
newVersion: "cli-v2.0.0", | ||
f: false, | ||
}, | ||
} | ||
for _, d := range data { | ||
d := d | ||
t.Run(d.name, func(t *testing.T) { | ||
t.Parallel() | ||
f, err := compareVersion(d.currentVersion, d.newVersion) | ||
if err != nil { | ||
if d.isErr { | ||
return | ||
} | ||
t.Fatal(err) | ||
} | ||
if d.isErr { | ||
t.Fatal("error must be returned") | ||
} | ||
if f != d.f { | ||
t.Fatalf("wanted %v, got %v", d.f, f) | ||
} | ||
}) | ||
} | ||
} |