refactor: use reflect.TypeFor instead of reflect.TypeOf and improve related tests (#2101)

* refactor: using reflect.TypeFor

Signed-off-by: suranmiao <solsui@outlook.com>

* refactor: remove unused reflect.TypeFor calls and improve test assertions

* refactor: simplify TestSetup by removing reflect.TypeFor

* test: enhance test assertions and improve parallel execution in TestSetup

---------

Signed-off-by: suranmiao <solsui@outlook.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
suranmiao
2025-12-10 07:54:54 +08:00
committed by GitHub
parent 8260aad9fd
commit 78382afb14
10 changed files with 75 additions and 123 deletions

View File

@@ -4,7 +4,6 @@ import (
"errors"
"os"
"path/filepath"
"reflect"
"testing"
"time"
@@ -33,16 +32,9 @@ func TestNewVM(t *testing.T) {
manager := GctScriptManager{
config: configHelper(true, true, maxTestVirtualMachines),
}
x := manager.New()
if x != nil {
t.Error("Should not create a VM when manager not started")
}
require.Nil(t, manager.New(), "New must not create a VM when manager not started")
manager.started = 1
x = manager.New()
xType := reflect.TypeOf(x).String()
if xType != "*vm.VM" {
t.Fatalf("vm.New should return pointer to VM instead received: %v", x)
}
require.NotNil(t, manager.New(), "New must create a VM when manager is started")
}
func TestVMLoad(t *testing.T) {