mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
ffc931aad1
* Added unit tag as argument. Added description to runTests command. Changed code generator to have unit build tag in generated unit test files. * Added unit build tag to all unit test files. * added to new unit test unit build tag * Update verify-go.yml * small fix --------- Co-authored-by: Muhammadali Nazarov <Muhammadali.Nazarov@acronis.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
//go:build unit
|
|
// +build unit
|
|
|
|
package versioning
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_applyVersioningModel(t *testing.T) {
|
|
type args struct {
|
|
model string
|
|
version string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
}{
|
|
{"maven - major", args{VersioningModelMajor, "1.2.3-7864387648746"}, "1"},
|
|
{"maven - major-minor", args{VersioningModelMajorMinor, "1.2.3-7864387648746"}, "1.2"},
|
|
{"maven - semantic", args{VersioningModelSemantic, "1.2.3-7864387648746"}, "1.2.3"},
|
|
{"maven - full", args{VersioningModelFull, "1.2.3-7864387648746"}, "1.2.3-7864387648746"},
|
|
{"python - major-minor", args{VersioningModelMajorMinor, "2.2.3.20200101"}, "2.2"},
|
|
{"leading zero", args{VersioningModelMajor, "0.0.1"}, "0"},
|
|
{"trailing zero", args{VersioningModelMajorMinor, "2.0"}, "2.0"},
|
|
{"invalid - unknown versioning model", args{"snapshot", "1.2.3-SNAPSHOT"}, ""},
|
|
{"invalid - incorrect version", args{VersioningModelMajor, ".2.3"}, ""},
|
|
{"invalid - version to short", args{VersioningModelSemantic, "1.2"}, "1.2.<no value>"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := ApplyVersioningModel(tt.args.model, tt.args.version)
|
|
if got != tt.want {
|
|
t.Errorf("ApplyVersioningModel() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|