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:
Brad Fitzpatrick
2023-08-30 10:21:56 -07:00
committed by Brad Fitzpatrick
parent 306b85b9a3
commit 9ce1f5c7d2
3 changed files with 17 additions and 13 deletions

View File

@@ -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)
}