Skip to content

Commit

Permalink
Merge pull request #87 from telekom-mms/feature/restore-env-after-vpn…
Browse files Browse the repository at this point in the history
…cscript-tests

Restore environment variables after vpncscript tests
  • Loading branch information
hwipl committed May 15, 2024
2 parents f3060d6 + f3e6406 commit 660a737
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/vpncscript/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ package vpncscript
import (
"os"
"reflect"
"strings"
"testing"
)

// setEnviron sets the environment in env.
func setEnviron(env []string) {
for _, e := range env {
pair := strings.SplitN(e, "=", 2)
os.Setenv(pair[0], pair[1])
}
}

// TestParseEnvironmentSplit tests parseEnvironmentSplit.
func TestParseEnvironmentSplit(t *testing.T) {
defer setEnviron(os.Environ())

// test empty environment
os.Clearenv()
for _, prefix := range []string{
Expand Down Expand Up @@ -329,6 +340,8 @@ func TestParseDisableAlwaysOnVPN(t *testing.T) {

// TestParseEnvironment tests parseEnvironment.
func TestParseEnvironment(t *testing.T) {
defer setEnviron(os.Environ())

// setup test environment
os.Clearenv()
for k, v := range map[string]string{
Expand Down

0 comments on commit 660a737

Please sign in to comment.