mac build and testing

This commit is contained in:
redanthrax 2022-06-24 08:49:47 -07:00
parent 41046d1d56
commit ce1b857b9a
3 changed files with 67 additions and 47 deletions

View file

@ -4,14 +4,19 @@ https://github.com/amidaware/tacticalrmm
#### building the agent - linux #### building the agent - linux
``` ```
env CGO_ENABLED=0 GOOS=<GOOS> GOARCH=<GOARCH> go build -ldflags "-s -w -X 'main.version=v2.0.4'" env CGO_ENABLED=0 GOOS=<GOOS> GOARCH=<GOARCH> go build -ldflags "-s -w -X 'main.version=v2.0.4'"
example: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4' -o build/output/rmmagent" example: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/rmmagent
```
#### building the agent - macos
```
env GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/rmmagent
``` ```
#### building the agent - windows #### building the agent - windows
``` ```
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo
go generate go generate
$env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w -X 'main.version=v2.0.4' -o build/output/tacticalrmm.exe" $env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w -X 'main.version=v2.0.4'" -o build/output/tacticalrmm.exe
``` ```
### tests ### tests

View file

@ -18,3 +18,24 @@ func TestAgentId(t *testing.T) {
t.Logf("AgentID: %s", a.AgentID) t.Logf("AgentID: %s", a.AgentID)
} }
} }
func TestSystemRebootRequired(t *testing.T) {
a := New(lg, version)
result, err := a.SystemRebootRequired()
if err != nil {
t.Error(err)
}
t.Logf("Result: %t", result)
}
func TestLoggedOnUser(t *testing.T) {
a := New(lg, version)
result := a.LoggedOnUser()
if result == "" {
t.Errorf("Could not get logged on user.")
}
t.Logf("Result: %s", result)
}

View file

@ -1,50 +1,42 @@
package agent package agent
import ( import (
"testing"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
"testing"
) )
func TestInstall(t *testing.T) { func TestInstall(t *testing.T) {
testTable := []struct { testTable := []struct {
name string name string
expectedError error expectedError error
version string version string
log logrus.Logger
}{ }{
{ {
name: "Install", name: "Install",
expectedError: nil, expectedError: nil,
version: "2.0.4", version: "2.0.4",
log: *logrus.New(),
}, },
{ {
name: "Install Error", name: "Install Error",
expectedError: nil, expectedError: nil,
version: "bad ver", version: "bad ver",
log: *logrus.New(),
}, },
} }
for _, tt := range testTable { for _, tt := range testTable {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
a := New(&tt.log, tt.version)
})
}
var (
version = "2.0.4"
log = logrus.New()
)
a := New(log, version)
viper.SetConfigName("testargs.json") viper.SetConfigName("testargs.json")
viper.SetConfigType("json") viper.SetConfigType("json")
viper.AddConfigPath(".") viper.AddConfigPath(".")
viper.ReadInConfig() viper.ReadInConfig()
installer := Installer { installer := Installer{
RMM: viper.GetString("api"), RMM: viper.GetString("api"),
ClientID: viper.GetInt("clientid"), ClientID: viper.GetInt("clientid"),
SiteID: viper.GetInt("siteid"), SiteID: viper.GetInt("siteid"),
@ -65,4 +57,6 @@ func TestInstall(t *testing.T) {
} }
a.Install(&installer) a.Install(&installer)
})
}
} }