additional functions and testing
This commit is contained in:
parent
f0cb4f4b3f
commit
6853f1639e
3 changed files with 58 additions and 5 deletions
|
|
@ -3,10 +3,23 @@
|
|||
|
||||
package software
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/system"
|
||||
)
|
||||
|
||||
func GetInstalledSoftware() ([]Software, error) {
|
||||
return []Software{}, nil
|
||||
}
|
||||
opts := system.NewCMDOpts()
|
||||
opts.Command = "find /usr/share/applications -maxdepth 1 -type f -exec basename {} .desktop \\; | sort"
|
||||
result := system.CmdV2(opts)
|
||||
softwares := strings.Split(result.Stdout, "\n")
|
||||
software := []Software{}
|
||||
for _, s := range softwares {
|
||||
software = append(software, Software {
|
||||
Name: s,
|
||||
})
|
||||
}
|
||||
|
||||
func InstallChoco() {}
|
||||
|
||||
func InstallWithChoco(name string) (string, error) { return "", nil }
|
||||
return software, nil
|
||||
}
|
||||
40
agent/umi/umi_unix_test.go
Normal file
40
agent/umi/umi_unix_test.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package umi_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/umi"
|
||||
)
|
||||
|
||||
func TestGetInfo(t *testing.T) {
|
||||
testTable := []struct {
|
||||
name string
|
||||
expected map[string]interface{}
|
||||
atLeast int
|
||||
expectedErrors []error
|
||||
}{
|
||||
{
|
||||
name: "Get info",
|
||||
expected: make(map[string]interface{}),
|
||||
atLeast: 1,
|
||||
expectedErrors: []error{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testTable {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result, errs := umi.GetInfo()
|
||||
if len(result) < tt.atLeast {
|
||||
t.Errorf("expected at least %d, got %d", tt.atLeast, len(result))
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(tt.expectedErrors, errs) {
|
||||
t.Errorf("expected (%v), got (%v)", tt.expectedErrors, errs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue