mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
control/controlclient: unexport Status.state, add test-only accessor
Updates #cleanup Updates #1909 Change-Id: I38dcde6fa0de0f58ede4529992cee2e36de33dd6 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
306b85b9a3
commit
9ce1f5c7d2
@ -666,8 +666,8 @@ func (c *Auto) sendStatus(who string, err error, url string, nm *netmap.NetworkM
|
||||
URL: url,
|
||||
Persist: p,
|
||||
NetMap: nm,
|
||||
State: state,
|
||||
Err: err,
|
||||
state: state,
|
||||
}
|
||||
c.observer.SetControlClientStatus(new)
|
||||
|
||||
|
@ -21,7 +21,7 @@ func fieldsOf(t reflect.Type) (fields []string) {
|
||||
|
||||
func TestStatusEqual(t *testing.T) {
|
||||
// Verify that the Equal method stays in sync with reality
|
||||
equalHandles := []string{"LoginFinished", "LogoutFinished", "Err", "URL", "NetMap", "State", "Persist"}
|
||||
equalHandles := []string{"LoginFinished", "LogoutFinished", "Err", "URL", "NetMap", "Persist", "state"}
|
||||
if have := fieldsOf(reflect.TypeOf(Status{})); !reflect.DeepEqual(have, equalHandles) {
|
||||
t.Errorf("Status.Equal check might be out of sync\nfields: %q\nhandled: %q\n",
|
||||
have, equalHandles)
|
||||
@ -52,13 +52,13 @@ func TestStatusEqual(t *testing.T) {
|
||||
true,
|
||||
},
|
||||
{
|
||||
&Status{State: StateNew},
|
||||
&Status{State: StateNew},
|
||||
&Status{state: StateNew},
|
||||
&Status{state: StateNew},
|
||||
true,
|
||||
},
|
||||
{
|
||||
&Status{State: StateNew},
|
||||
&Status{State: StateAuthenticated},
|
||||
&Status{state: StateNew},
|
||||
&Status{state: StateAuthenticated},
|
||||
false,
|
||||
},
|
||||
{
|
||||
|
@ -69,14 +69,18 @@ type Status struct {
|
||||
URL string // interactive URL to visit to finish logging in
|
||||
NetMap *netmap.NetworkMap // server-pushed configuration
|
||||
|
||||
// The internal state should not be exposed outside this
|
||||
// package, but we have some automated tests elsewhere that need to
|
||||
// use them. Please don't use these fields.
|
||||
// TODO(apenwarr): Unexport or remove these.
|
||||
State State
|
||||
Persist *persist.PersistView // locally persisted configuration
|
||||
|
||||
// state is the internal state. It should not be exposed outside this
|
||||
// package, but we have some automated tests elsewhere that need to
|
||||
// use it via the StateForTest accessor.
|
||||
// TODO(apenwarr): Unexport or remove these.
|
||||
state State
|
||||
}
|
||||
|
||||
// StateForTest returns the internal state of s for tests only.
|
||||
func (s *Status) StateForTest() State { return s.state }
|
||||
|
||||
// Equal reports whether s and s2 are equal.
|
||||
func (s *Status) Equal(s2 *Status) bool {
|
||||
if s == nil && s2 == nil {
|
||||
@ -89,7 +93,7 @@ func (s *Status) Equal(s2 *Status) bool {
|
||||
s.URL == s2.URL &&
|
||||
reflect.DeepEqual(s.Persist, s2.Persist) &&
|
||||
reflect.DeepEqual(s.NetMap, s2.NetMap) &&
|
||||
s.State == s2.State
|
||||
s.state == s2.state
|
||||
}
|
||||
|
||||
func (s Status) String() string {
|
||||
@ -97,5 +101,5 @@ func (s Status) String() string {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s.State.String() + " " + string(b)
|
||||
return s.state.String() + " " + string(b)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user