Linting fixes

This commit is contained in:
Graham Davison 2023-07-17 11:34:33 -07:00
parent d179b686d9
commit 344e9de6b9
3 changed files with 18 additions and 20 deletions

View File

@ -203,10 +203,6 @@ func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
return stateMgr, nil return stateMgr, nil
} }
func (b *Backend) client() *RemoteClient {
return &RemoteClient{}
}
func (b *Backend) path(name string) string { func (b *Backend) path(name string) string {
if name == backend.DefaultStateName { if name == backend.DefaultStateName {
return b.keyName return b.keyName

View File

@ -1038,7 +1038,9 @@ func TestBackendExtraPaths(t *testing.T) {
// Write the first state // Write the first state
stateMgr := &remote.State{Client: client} stateMgr := &remote.State{Client: client}
stateMgr.WriteState(s1) if err := stateMgr.WriteState(s1); err != nil {
t.Fatal(err)
}
if err := stateMgr.PersistState(nil); err != nil { if err := stateMgr.PersistState(nil); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1048,7 +1050,9 @@ func TestBackendExtraPaths(t *testing.T) {
// states are equal, the state will not Put to the remote // states are equal, the state will not Put to the remote
client.path = b.path("s2") client.path = b.path("s2")
stateMgr2 := &remote.State{Client: client} stateMgr2 := &remote.State{Client: client}
stateMgr2.WriteState(s2) if err := stateMgr2.WriteState(s2); err != nil {
t.Fatal(err)
}
if err := stateMgr2.PersistState(nil); err != nil { if err := stateMgr2.PersistState(nil); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1061,7 +1065,9 @@ func TestBackendExtraPaths(t *testing.T) {
// put a state in an env directory name // put a state in an env directory name
client.path = b.workspaceKeyPrefix + "/error" client.path = b.workspaceKeyPrefix + "/error"
stateMgr.WriteState(states.NewState()) if err := stateMgr.WriteState(states.NewState()); err != nil {
t.Fatal(err)
}
if err := stateMgr.PersistState(nil); err != nil { if err := stateMgr.PersistState(nil); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1071,7 +1077,9 @@ func TestBackendExtraPaths(t *testing.T) {
// add state with the wrong key for an existing env // add state with the wrong key for an existing env
client.path = b.workspaceKeyPrefix + "/s2/notTestState" client.path = b.workspaceKeyPrefix + "/s2/notTestState"
stateMgr.WriteState(states.NewState()) if err := stateMgr.WriteState(states.NewState()); err != nil {
t.Fatal(err)
}
if err := stateMgr.PersistState(nil); err != nil { if err := stateMgr.PersistState(nil); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1105,12 +1113,14 @@ func TestBackendExtraPaths(t *testing.T) {
if s2Mgr.(*remote.State).StateSnapshotMeta().Lineage == s2Lineage { if s2Mgr.(*remote.State).StateSnapshotMeta().Lineage == s2Lineage {
t.Fatal("state s2 was not deleted") t.Fatal("state s2 was not deleted")
} }
s2 = s2Mgr.State() _ = s2Mgr.State() // We need the side-effect
s2Lineage = stateMgr.StateSnapshotMeta().Lineage s2Lineage = stateMgr.StateSnapshotMeta().Lineage
// add a state with a key that matches an existing environment dir name // add a state with a key that matches an existing environment dir name
client.path = b.workspaceKeyPrefix + "/s2/" client.path = b.workspaceKeyPrefix + "/s2/"
stateMgr.WriteState(states.NewState()) if err := stateMgr.WriteState(states.NewState()); err != nil {
t.Fatal(err)
}
if err := stateMgr.PersistState(nil); err != nil { if err := stateMgr.PersistState(nil); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -18,11 +18,7 @@ func diagnosticComparer(l, r tfdiags.Diagnostic) bool {
if len(lp) != len(rp) { if len(lp) != len(rp) {
return false return false
} }
if !lp.Equals(rp) { return lp.Equals(rp)
return false
}
return true
} }
// diagnosticSummaryComparer is a Comparer function for use with cmp.Diff to compare // diagnosticSummaryComparer is a Comparer function for use with cmp.Diff to compare
@ -34,9 +30,5 @@ func diagnosticSummaryComparer(l, r tfdiags.Diagnostic) bool {
ld := l.Description() ld := l.Description()
rd := r.Description() rd := r.Description()
if ld.Summary != rd.Summary { return ld.Summary == rd.Summary
return false
}
return true
} }