removed some unix tests

This commit is contained in:
redanthrax 2022-06-28 14:34:32 -07:00
parent e926980ae5
commit f20f589fbf
8 changed files with 173 additions and 187 deletions

View file

@ -23,14 +23,6 @@ func TestGetDisks(t *testing.T) {
t.Logf("Result: %v", disks)
}
func TestAgentId(t *testing.T) {
if a.AgentID == "" {
t.Error("AgentID not set")
} else {
t.Logf("AgentID: %s", a.AgentID)
}
}
func TestSystemRebootRequired(t *testing.T) {
result, err := a.SystemRebootRequired()
if err != nil {

View file

@ -1,62 +1,62 @@
package agent
import (
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"testing"
)
//import (
//"github.com/sirupsen/logrus"
//"github.com/spf13/viper"
//"testing"
//)
func TestInstall(t *testing.T) {
testTable := []struct {
name string
expectedError error
version string
log logrus.Logger
}{
//func TestInstall(t *testing.T) {
//testTable := []struct {
//name string
//expectedError error
//version string
//log logrus.Logger
//}{
//{
//name: "Install",
//expectedError: nil,
//version: "2.0.4",
//log: *logrus.New(),
//},
{
name: "Install Error",
expectedError: nil,
version: "bad ver",
log: *logrus.New(),
},
}
//{
//name: "Install Error",
//expectedError: nil,
//version: "bad ver",
//log: *logrus.New(),
//},
//}
for _, tt := range testTable {
t.Run(tt.name, func(t *testing.T) {
a := New(&tt.log, tt.version)
//for _, tt := range testTable {
//t.Run(tt.name, func(t *testing.T) {
//a := New(&tt.log, tt.version)
viper.SetConfigName("testargs.json")
viper.SetConfigType("json")
viper.AddConfigPath(".")
viper.ReadInConfig()
//viper.SetConfigName("testargs.json")
//viper.SetConfigType("json")
//viper.AddConfigPath(".")
//viper.ReadInConfig()
installer := Installer{
RMM: viper.GetString("api"),
ClientID: viper.GetInt("clientid"),
SiteID: viper.GetInt("siteid"),
Description: viper.GetString("description"),
AgentType: viper.GetString("agenttype"),
Power: viper.GetBool("power"),
RDP: viper.GetBool("rdp"),
Ping: viper.GetBool("ping"),
Token: viper.GetString("token"),
LocalMesh: viper.GetString("localmesh"),
Cert: viper.GetString("cert"),
Proxy: viper.GetString("proxy"),
Timeout: viper.GetDuration("timeout"),
Silent: viper.GetBool("silent"),
NoMesh: viper.GetBool("nomesh"),
MeshDir: viper.GetString("meshdir"),
MeshNodeID: viper.GetString("meshnodeid"),
}
//installer := Installer{
//RMM: viper.GetString("api"),
//ClientID: viper.GetInt("clientid"),
//SiteID: viper.GetInt("siteid"),
//Description: viper.GetString("description"),
//AgentType: viper.GetString("agenttype"),
//Power: viper.GetBool("power"),
//RDP: viper.GetBool("rdp"),
//Ping: viper.GetBool("ping"),
//Token: viper.GetString("token"),
//LocalMesh: viper.GetString("localmesh"),
//Cert: viper.GetString("cert"),
//Proxy: viper.GetString("proxy"),
//Timeout: viper.GetDuration("timeout"),
//Silent: viper.GetBool("silent"),
//NoMesh: viper.GetBool("nomesh"),
//MeshDir: viper.GetString("meshdir"),
//MeshNodeID: viper.GetString("meshnodeid"),
//}
a.Install(&installer)
})
}
}
//a.Install(&installer)
//})
//}
//}

View file

@ -39,12 +39,10 @@ func TestGetUpdates(t *testing.T) {
testTable := []struct {
name string
expectedError error
atLeast int
}{
{
name: "Get Updates",
expectedError: nil,
atLeast: 1,
},
}
@ -55,10 +53,6 @@ func TestGetUpdates(t *testing.T) {
if !errors.Is(tt.expectedError, err) {
t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
}
if len(result) < tt.atLeast {
t.Errorf("expected at least %d, got %d", tt.atLeast, len(result))
}
})
}
}

View file

@ -1,42 +1,42 @@
package checks_test
import (
"errors"
"testing"
//import (
//"errors"
//"testing"
"github.com/amidaware/rmmagent/agent/tactical/checks"
"github.com/amidaware/rmmagent/agent/tactical/config"
)
//"github.com/amidaware/rmmagent/agent/tactical/checks"
//"github.com/amidaware/rmmagent/agent/tactical/config"
//)
func TestGetCheckInterval(t *testing.T) {
config := config.NewAgentConfig()
testTable := []struct {
name string
interval int
expectedError error
}{
{
name: "Get Check Interval",
interval: 1,
expectedError: nil,
},
}
//func TestGetCheckInterval(t *testing.T) {
//config := config.NewAgentConfig()
//testTable := []struct {
//name string
//interval int
//expectedError error
//}{
//{
//name: "Get Check Interval",
//interval: 1,
//expectedError: nil,
//},
//}
for _, tt := range testTable {
t.Run(tt.name, func(t *testing.T) {
result, err := checks.GetCheckInterval(config.AgentID)
if result < tt.interval {
t.Errorf("expected greater interval than %d, got %d", tt.interval, result)
}
//for _, tt := range testTable {
//t.Run(tt.name, func(t *testing.T) {
//result, err := checks.GetCheckInterval(config.AgentID)
//if result < tt.interval {
//t.Errorf("expected greater interval than %d, got %d", tt.interval, result)
//}
if !errors.Is(tt.expectedError, err) {
t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
}
})
}
}
//if !errors.Is(tt.expectedError, err) {
//t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
//}
//})
//}
//}
//this test runs forever
////this test runs forever
//func TestCheckRunner(t *testing.T) {
//config := config.NewAgentConfig()
//testTable := []struct {
@ -59,28 +59,28 @@ func TestGetCheckInterval(t *testing.T) {
//}
//}
func TestRunChecks(t *testing.T) {
config := config.NewAgentConfig()
testTable := []struct {
name string
expectedError error
force bool
agentId string
}{
{
name: "Run Checks",
expectedError: nil,
force: false,
agentId: config.AgentID,
},
}
//func TestRunChecks(t *testing.T) {
//config := config.NewAgentConfig()
//testTable := []struct {
//name string
//expectedError error
//force bool
//agentId string
//}{
//{
//name: "Run Checks",
//expectedError: nil,
//force: false,
//agentId: config.AgentID,
//},
//}
for _, tt := range testTable {
t.Run(tt.name, func(t *testing.T){
err := checks.RunChecks(tt.agentId, tt.force)
if !errors.Is(tt.expectedError, err) {
t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
}
})
}
}
//for _, tt := range testTable {
//t.Run(tt.name, func(t *testing.T){
//err := checks.RunChecks(tt.agentId, tt.force)
//if !errors.Is(tt.expectedError, err) {
//t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
//}
//})
//}
//}

View file

@ -1,18 +1,18 @@
package service_test
import (
"errors"
"testing"
//import (
//"errors"
//"testing"
"github.com/amidaware/rmmagent/agent/tactical/service"
)
//"github.com/amidaware/rmmagent/agent/tactical/service"
//)
func TestAgentSvc(t *testing.T) {
testTable := []struct {
name string
expectedError error
version string
}{
//func TestAgentSvc(t *testing.T) {
//testTable := []struct {
//name string
//expectedError error
//version string
//}{
//{
//name: "Agent Svc",
//expectedError: nil,
@ -23,14 +23,14 @@ func TestAgentSvc(t *testing.T) {
//expectedError: nil,
//version: "bad version",
//},
}
//}
for _, tt := range testTable {
t.Run(tt.name, func(t *testing.T) {
err := service.AgentSvc(tt.version)
if errors.Is(tt.expectedError, err) {
t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
}
})
}
}
//for _, tt := range testTable {
//t.Run(tt.name, func(t *testing.T) {
//err := service.AgentSvc(tt.version)
//if errors.Is(tt.expectedError, err) {
//t.Errorf("expected (%v), got (%v)", tt.expectedError, err)
//}
//})
//}
//}

View file

@ -1,16 +1,16 @@
package shared_test
import (
"testing"
//import (
//"testing"
"github.com/amidaware/rmmagent/agent/tactical/shared"
)
//"github.com/amidaware/rmmagent/agent/tactical/shared"
//)
func TestGetPythonBin(t *testing.T) {
pybin := shared.GetPythonBin()
if pybin == "" {
t.Errorf("expected path, got %s", pybin)
}
//func TestGetPythonBin(t *testing.T) {
//pybin := shared.GetPythonBin()
//if pybin == "" {
//t.Errorf("expected path, got %s", pybin)
//}
t.Logf("result: %s", pybin)
}
//t.Logf("result: %s", pybin)
//}

View file

@ -1,16 +1,16 @@
package tactical_test
import (
"testing"
//import (
//"testing"
"github.com/amidaware/rmmagent/agent/tactical"
)
//"github.com/amidaware/rmmagent/agent/tactical"
//)
func TestGetVersion(t *testing.T) {
version := tactical.GetVersion()
if version == "" {
t.Errorf("expected version, got empty version")
}
//func TestGetVersion(t *testing.T) {
//version := tactical.GetVersion()
//if version == "" {
//t.Errorf("expected version, got empty version")
//}
t.Logf("got version %s", version)
}
//t.Logf("got version %s", version)
//}

View file

@ -3,20 +3,20 @@
package tactical_test
import (
"testing"
//import (
//"testing"
"github.com/amidaware/rmmagent/agent/tactical"
)
//"github.com/amidaware/rmmagent/agent/tactical"
//)
func TestNewAgentConfig(t *testing.T) {
config := tactical.NewAgentConfig()
if config.BaseURL == "" {
t.Fatal("Could not get config")
}
//func TestNewAgentConfig(t *testing.T) {
//config := tactical.NewAgentConfig()
//if config.BaseURL == "" {
//t.Fatal("Could not get config")
//}
t.Logf("Config BaseURL: %s", config.BaseURL)
}
//t.Logf("Config BaseURL: %s", config.BaseURL)
//}
//func TestAgentUpdate(t *testing.T) {
//url := "https://github.com/redanthrax/rmmagent/releases/download/v2.0.4/linuxagent"
@ -28,20 +28,20 @@ func TestNewAgentConfig(t *testing.T) {
//t.Log("Agent update resulted in true")
//}
func TestAgentUninstall(t *testing.T) {
result := tactical.AgentUninstall("foo")
if !result {
t.Fatal("Agent uninstall resulted in error")
}
//func TestAgentUninstall(t *testing.T) {
//result := tactical.AgentUninstall("foo")
//if !result {
//t.Fatal("Agent uninstall resulted in error")
//}
t.Log("Agent uninstall was true")
}
//t.Log("Agent uninstall was true")
//}
func TestNixMeshNodeID(t *testing.T) {
nodeid := tactical.NixMeshNodeID()
if nodeid == "" {
t.Fatal("Unable to get mesh node id")
}
//func TestNixMeshNodeID(t *testing.T) {
//nodeid := tactical.NixMeshNodeID()
//if nodeid == "" {
//t.Fatal("Unable to get mesh node id")
//}
t.Logf("MeshNodeID: %s", nodeid)
}
//t.Logf("MeshNodeID: %s", nodeid)
//}