2024-03-17 15:41:25 +03:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestModMajor(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
modpath string
|
|
|
|
}
|
|
|
|
var tests = []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want string
|
|
|
|
want1 bool
|
|
|
|
}{
|
|
|
|
{"Test #1",
|
|
|
|
args{
|
|
|
|
"github.com/jackc/chunkreader/v2",
|
|
|
|
},
|
|
|
|
"v2",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
{"Test #2",
|
|
|
|
args{
|
|
|
|
"github.com/jackc/chunkreader",
|
|
|
|
},
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
{"Test #3",
|
|
|
|
args{
|
|
|
|
"gopkg.in/yaml.v2",
|
|
|
|
},
|
|
|
|
"v2",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
{"Test #4",
|
|
|
|
args{
|
|
|
|
"github.com/jackc/chunkreader/v1",
|
|
|
|
},
|
|
|
|
"",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
got, got1 := ModMajor(tt.args.modpath)
|
|
|
|
if got != tt.want {
|
2024-03-17 16:45:46 +03:00
|
|
|
t.Error("ModMajor() got = %v, want %v", got, tt.want)
|
2024-03-17 15:41:25 +03:00
|
|
|
}
|
|
|
|
if got1 != tt.want1 {
|
2024-03-17 16:45:46 +03:00
|
|
|
t.Error("ModMajor() got1 = %v, want %v", got1, tt.want1)
|
2024-03-17 15:41:25 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|