os exit when option is true

This commit is contained in:
JieJhih Jhang
2019-04-24 16:32:11 +08:00
parent 6c55e2d206
commit 48f431aae5
4 changed files with 32 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package app
import (
"errors"
"fmt"
"io/ioutil"
"os"
@@ -108,7 +109,6 @@ func TestProxyServerWithCleanupAndExit(t *testing.T) {
assert.Nil(t, err, "unexpected error in NewProxyServer, addr: %s", addr)
assert.NotNil(t, proxyserver, "nil proxy server obj, addr: %s", addr)
assert.NotNil(t, proxyserver.IptInterface, "nil iptables intf, addr: %s", addr)
assert.True(t, proxyserver.CleanupAndExit, "false CleanupAndExit, addr: %s", addr)
// Clean up config for next test case
configz.Delete(kubeproxyconfig.GroupName)
@@ -540,6 +540,11 @@ func (s *fakeProxyServerLongRun) Run() error {
}
}
// CleanupAndExit runs in the specified ProxyServer.
func (s *fakeProxyServerLongRun) CleanupAndExit() error {
return nil
}
type fakeProxyServerError struct{}
// Run runs the specified ProxyServer.
@@ -549,3 +554,8 @@ func (s *fakeProxyServerError) Run() error {
return fmt.Errorf("mocking error from ProxyServer.Run()")
}
}
// CleanupAndExit runs in the specified ProxyServer.
func (s *fakeProxyServerError) CleanupAndExit() error {
return errors.New("mocking error from ProxyServer.CleanupAndExit()")
}