Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c18716e
commit f691f10
Showing
5 changed files
with
114 additions
and
7 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
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,59 @@ | ||
package gobrew | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestExtractMajorVersion(t *testing.T) { | ||
type args struct { | ||
version string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "extracts major version", | ||
args: args{ | ||
version: "1.16.5", | ||
}, | ||
want: "1.16", | ||
}, | ||
{ | ||
name: "extracts major version if already major version", | ||
args: args{ | ||
version: "1.16", | ||
}, | ||
want: "1.16", | ||
}, | ||
{ | ||
name: "extracts major version with extra parts", | ||
args: args{ | ||
version: "", | ||
}, | ||
want: "", | ||
}, | ||
{ | ||
name: "extracts major version rc", | ||
args: args{ | ||
version: "1.21rc1", | ||
}, | ||
want: "1.21", | ||
}, | ||
{ | ||
name: "extracts major version beta", | ||
args: args{ | ||
version: "1.21beta1", | ||
}, | ||
want: "1.21", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := ExtractMajorVersion(tt.args.version); got != tt.want { | ||
t.Errorf("ExtractMajorVersion() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |