2 * ============LICENSE_START=======================================================
3 * oom-certservice-k8s-external-provider
4 * ================================================================================
5 * Copyright (C) 2020 Nokia. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
28 "github.com/stretchr/testify/assert"
31 func Test_shouldParseArguments_defaultValues(t *testing.T) {
33 "first-arg-is-omitted-by-method-parse-arguments-so-this-only-a-placeholder"}
34 flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
36 metricsAddr, logLevel, enableLeaderElection := parseInputArguments()
38 assert.Equal(t, ":8080", metricsAddr)
39 assert.Equal(t, "debug", logLevel)
40 assert.False(t, enableLeaderElection)
43 func Test_shouldParseArguments_valuesFromCLI(t *testing.T) {
45 "first-arg-is-omitted-by-method-parse-arguments-so-this-only-a-placeholder",
46 "--metrics-addr=127.0.0.1:555",
48 "--enable-leader-election=true"}
49 flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
51 metricsAddr, logLevel, enableLeaderElection := parseInputArguments()
53 assert.Equal(t, "127.0.0.1:555", metricsAddr)
54 assert.Equal(t, "error", logLevel)
55 assert.True(t, enableLeaderElection)