mirror of
https://github.com/rizinorg/rz-pm.git
synced 2026-11-07 06:45:59 -10:00
Using a real plugin means: 1. we need to be online during testing 2. if the plugin has a different version from rizin on the machine often it won't event compile This commit introduces a fake plugin in the simpleplugin directory. During testing, an HTTP server is spawned. The .tar.gz is created and served on-the-fly to every test that asks for it.
26 lines
544 B
Go
26 lines
544 B
Go
package pkg
|
|
|
|
import "testing"
|
|
|
|
func TestGetMajorMinorVersion(t *testing.T) {
|
|
tests := []struct {
|
|
version string
|
|
want string
|
|
}{
|
|
{"1.2.3", "1.2"},
|
|
{"10.20.30", "10.20"},
|
|
{"0.1.2", "0.1"},
|
|
{"5.6", "5.6"}, // Edge case with no patch version
|
|
{"1", "1.0"}, // Edge case with only major version
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.version, func(t *testing.T) {
|
|
got := GetMajorMinorVersion(tt.version)
|
|
if got != tt.want {
|
|
t.Errorf("GetMajorMinorVersion(%q) = %q; want %q", tt.version, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|