mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

In preperation for adding the ability to join a machine to an existing cluster force the user to specify whether they expect this to me a new cluster or an active one. The error for not specifying the initial-cluster-state is: ``` etcd: initial cluster state unset and no wal found ```
28 lines
417 B
Go
28 lines
417 B
Go
package etcdserver
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestClusterStateSet(t *testing.T) {
|
|
tests := []struct {
|
|
val string
|
|
pass bool
|
|
}{
|
|
// known values
|
|
{"new", true},
|
|
|
|
// unrecognized values
|
|
{"foo", false},
|
|
{"", false},
|
|
}
|
|
|
|
for i, tt := range tests {
|
|
pf := new(ClusterState)
|
|
err := pf.Set(tt.val)
|
|
if tt.pass != (err == nil) {
|
|
t.Errorf("#%d: want pass=%t, but got err=%v", i, tt.pass, err)
|
|
}
|
|
}
|
|
}
|