Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues with tests #381

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rook/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestPackageFromDir(t *testing.T) {
"Southclaws/pawn-errors:1.2.3",
},
Runtime: &run.Runtime{
Echo: &[]string{"-"}[0],
Echo: nil,
Version: "0.3.7",
Platform: runtime.GOOS,
RCONPassword: &[]string{"password"}[0],
Expand All @@ -56,7 +56,7 @@ func TestPackageFromDir(t *testing.T) {
"Southclaws/pawn-errors:1.2.3",
},
Runtime: &run.Runtime{
Echo: &[]string{"-"}[0],
Echo: nil,
Version: "0.3.7",
Platform: runtime.GOOS,
RCONPassword: &[]string{"password"}[0],
Expand Down
5 changes: 5 additions & 0 deletions run/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func (cfg Runtime) Validate() (err error) {
return errors.New("Mode empty")
}

if cfg.Echo == nil {
cfg.Echo = new(string)
*cfg.Echo = ""
}

return
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/Southclaws/sampctl/run"
)

var echoMessage = "echo - loading server.cfg generated by sampctl - do not edit this file by hand.\n"
var echoMessage = "echo loading server.cfg generated by sampctl - do not edit this file by hand."

// GenerateServerCfg creates a settings file in the SA:MP "server.cfg" format at the specified location
// nolint:gocyclo
Expand All @@ -32,7 +32,7 @@ func GenerateServerCfg(cfg *run.Runtime) (err error) {

// make some minor changes to the cfg before using it
adjustForOS(cfg.WorkingDir, cfg.Platform, cfg)
file.WriteString(echoMessage)
file.WriteString(echoMessage + "\n")

v := reflect.ValueOf(*cfg)
t := reflect.TypeOf(*cfg)
Expand Down Expand Up @@ -68,7 +68,7 @@ func GenerateServerCfg(cfg *run.Runtime) (err error) {
line, err = fromString(name, fieldval, required, defaultValue)
case "[]string":
line, err = fromSlice(name, fieldval, required, numbered)
case "[]types.Plugin":
case "[]run.Plugin":
line, err = fromSlice(name, fieldval, required, numbered)
case "*bool":
line, err = fromBool(name, fieldval, required, defaultValue)
Expand Down
2 changes: 1 addition & 1 deletion runtime/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func LoadEnvironmentVariables(cfg *run.Runtime) {
// todo: allow filterscripts via env vars
print.Warn("cannot set filterscripts via environment variables yet")

case "[]runtime.Plugin":
case "[]run.Plugin":
// todo: plugins via env vars
print.Warn("cannot set plugins via environment variables yet")

Expand Down
2 changes: 1 addition & 1 deletion runtime/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestNewConfigFromEnvironment(t *testing.T) {
Format: "json",
Version: "0.3.7",
Mode: run.Server,
Echo: &[]string{"-"}[0],
Echo: nil,
Gamemodes: []string{
"rivershell",
"baserace",
Expand Down