mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
commit
e01ae2c083
@ -166,3 +166,81 @@ func TestConfigParsingConflictClusteringFlags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfigIsNewCluster(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
state string
|
||||||
|
wIsNew bool
|
||||||
|
}{
|
||||||
|
{clusterStateFlagExisting, false},
|
||||||
|
{clusterStateFlagNew, true},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
cfg := NewConfig()
|
||||||
|
if err := cfg.clusterState.Set(tt.state); err != nil {
|
||||||
|
t.Fatalf("#%d: unexpected clusterState.Set error: %v", i, err)
|
||||||
|
}
|
||||||
|
if g := cfg.isNewCluster(); g != tt.wIsNew {
|
||||||
|
t.Errorf("#%d: isNewCluster = %v, want %v", i, g, tt.wIsNew)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigIsProxy(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
proxy string
|
||||||
|
wIsProxy bool
|
||||||
|
}{
|
||||||
|
{proxyFlagOff, false},
|
||||||
|
{proxyFlagReadonly, true},
|
||||||
|
{proxyFlagOn, true},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
cfg := NewConfig()
|
||||||
|
if err := cfg.proxy.Set(tt.proxy); err != nil {
|
||||||
|
t.Fatalf("#%d: unexpected proxy.Set error: %v", i, err)
|
||||||
|
}
|
||||||
|
if g := cfg.isProxy(); g != tt.wIsProxy {
|
||||||
|
t.Errorf("#%d: isProxy = %v, want %v", i, g, tt.wIsProxy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigIsReadonlyProxy(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
proxy string
|
||||||
|
wIsReadonly bool
|
||||||
|
}{
|
||||||
|
{proxyFlagOff, false},
|
||||||
|
{proxyFlagReadonly, true},
|
||||||
|
{proxyFlagOn, false},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
cfg := NewConfig()
|
||||||
|
if err := cfg.proxy.Set(tt.proxy); err != nil {
|
||||||
|
t.Fatalf("#%d: unexpected proxy.Set error: %v", i, err)
|
||||||
|
}
|
||||||
|
if g := cfg.isReadonlyProxy(); g != tt.wIsReadonly {
|
||||||
|
t.Errorf("#%d: isReadonlyProxy = %v, want %v", i, g, tt.wIsReadonly)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigShouldFallbackToProxy(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
fallback string
|
||||||
|
wFallback bool
|
||||||
|
}{
|
||||||
|
{fallbackFlagProxy, true},
|
||||||
|
{fallbackFlagExit, false},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
cfg := NewConfig()
|
||||||
|
if err := cfg.fallback.Set(tt.fallback); err != nil {
|
||||||
|
t.Fatalf("#%d: unexpected fallback.Set error: %v", i, err)
|
||||||
|
}
|
||||||
|
if g := cfg.shouldFallbackToProxy(); g != tt.wFallback {
|
||||||
|
t.Errorf("#%d: shouldFallbackToProxy = %v, want %v", i, g, tt.wFallback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2014 CoreOS, Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package etcdmain
|
package etcdmain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user