Files
rz-pm/pkg/utils_test.go
VaiTon 5aafd7a4f3 Create a custom fake simple plugin for testing (#60)
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.
2025-06-14 16:50:19 +08:00

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)
}
})
}
}