diff --git a/internal/vpncscript/cmd_test.go b/internal/vpncscript/cmd_test.go index f91da05d..b2810b89 100644 --- a/internal/vpncscript/cmd_test.go +++ b/internal/vpncscript/cmd_test.go @@ -30,6 +30,14 @@ func TestRun(t *testing.T) { t.Errorf("invalid token should return error") } + // test connect with config creation error, invalid VPN PID + os.Clearenv() + t.Setenv("reason", "connect") + t.Setenv("VPNPID", "not a valid vpn pid!") + if err := run([]string{"test"}); err == nil { + t.Errorf("invalid config should return error") + } + // prepare environment with not existing sockfile os.Clearenv() sockfile := filepath.Join(t.TempDir(), "sockfile") diff --git a/internal/vpncscript/env_test.go b/internal/vpncscript/env_test.go index 03b5dc78..1d623aed 100644 --- a/internal/vpncscript/env_test.go +++ b/internal/vpncscript/env_test.go @@ -11,7 +11,7 @@ import ( func setEnviron(env []string) { for _, e := range env { pair := strings.SplitN(e, "=", 2) - os.Setenv(pair[0], pair[1]) + _ = os.Setenv(pair[0], pair[1]) } }