fix variable name

上级 ef912eae
......@@ -57,9 +57,9 @@ func isInBlock(ip string, block string) (bool, error) {
// ExcludeIP will exclude the ip from the http(s)_proxy
func ExcludeIP(ip string) error {
if netIp := net.ParseIP(ip); netIp == nil {
if netIP := net.ParseIP(ip); netIP == nil {
if _, _, err := net.ParseCIDR(ip); err != nil {
return fmt.Errorf("ExcludeIP(%v) requires IP as a parameter or CIDR", ip)
return fmt.Errorf("ExcludeIP(%v) requires IP or CIDR as a parameter", ip)
}
}
return updateEnv(ip, "NO_PROXY")
......
......@@ -36,11 +36,9 @@ func TestIsValidEnv(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.env, func(t *testing.T) {
got := isValidEnv(tc.env)
if got != tc.want {
if got := isValidEnv(tc.env); got != tc.want {
t.Errorf("isValidEnv(\"%v\") got %v; want %v", tc.env, got, tc.want)
}
})
}
......@@ -140,16 +138,12 @@ func TestCheckEnv(t *testing.T) {
}
}()
// defer os.Setenv(tc.envName, originalEnv)
err := os.Setenv(tc.envName, tc.mockEnvValue) // setting up the test case
if err != nil {
if err := os.Setenv(tc.envName, tc.mockEnvValue); err != nil {
t.Error("Error setting env var for taste case")
}
got := checkEnv(tc.ip, tc.envName)
if got != tc.want {
if got := checkEnv(tc.ip, tc.envName); got != tc.want {
t.Errorf("CheckEnv(%v,%v) got %v ; want is %v", tc.ip, tc.envName, got, tc.want)
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册