From 3cc84b0a835b8d1ac6b30dd5ca845380b2ae6a79 Mon Sep 17 00:00:00 2001 From: inhere Date: Sat, 8 Jun 2019 12:20:09 +0800 Subject: [PATCH] fix: test on windows --- config_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config_test.go b/config_test.go index d0493c6..48103cc 100644 --- a/config_test.go +++ b/config_test.go @@ -3,6 +3,7 @@ package config import ( "bytes" "fmt" + "os" "testing" "github.com/gookit/config/v2/dotnev" @@ -267,9 +268,21 @@ func TestOptions(t *testing.T) { str := c.String("name") st.Equal("app", str) + // test: parse env name + shell := os.Getenv("SHELL") + // ensure env var is exist + if shell == "" { + _= os.Setenv("SHELL", "/usr/bin/bash") + } + str = c.String("envKey") st.NotContains(str, "${") + // revert + if shell != "" { + _= os.Setenv("SHELL", shell) + } + str = c.String("invalidEnvKey") st.Contains(str, "${")