backend/tests: use workspace argument in testLocksInWorkspace (#3405)

Signed-off-by: aleksandarss <aleksandar-sasa.calic@hotmail.com>
This commit is contained in:
aleksandarss
2025-10-24 22:11:01 +02:00
committed by GitHub
parent dd642bd53f
commit 730a60826c
2 changed files with 12 additions and 3 deletions

View File

@@ -246,6 +246,9 @@ func TestAccBackendAccessKeyBasic(t *testing.T) {
// TestBackendStateForceUnlock runs the both the TestBackendStateLocks test and the --force-unlock tests
backend.TestBackendStateForceUnlock(t, b1, b2)
backend.TestBackendStateLocksInWS(t, b1, b2, "foo")
backend.TestBackendStateForceUnlockInWS(t, b1, b2, "foo")
}
// TestAccBackendSASToken tests if the backend functions when using a SAS token.
@@ -301,6 +304,9 @@ func TestAccBackendSASToken(t *testing.T) {
})).(*Backend)
backend.TestBackendStateForceUnlock(t, b1, b2)
backend.TestBackendStateLocksInWS(t, b1, b2, "foo")
backend.TestBackendStateForceUnlockInWS(t, b1, b2, "foo")
}
// TestAccBackendServicePrincipalClientSecret tests if the backend functions when using a client ID and secret.
@@ -362,6 +368,9 @@ Please set TF_AZURE_TEST_CLIENT_ID and TF_AZURE_TEST_CLIENT_SECRET, either manua
// TestBackendStateForceUnlock runs the both the TestBackendStateLocks test and the --force-unlock tests
backend.TestBackendStateForceUnlock(t, b1, b2)
backend.TestBackendStateLocksInWS(t, b1, b2, "foo")
backend.TestBackendStateForceUnlockInWS(t, b1, b2, "foo")
}
// TestAccBackendServicePrincipalClientCertificate tests if the backend functions when using a PFX certificate file.

View File

@@ -379,7 +379,7 @@ func testLocksInWorkspace(t *testing.T, b1, b2 Backend, testForceUnlock bool, wo
t.Helper()
// Get the default state for each
b1StateMgr, err := b1.StateMgr(t.Context(), DefaultStateName)
b1StateMgr, err := b1.StateMgr(t.Context(), workspace)
if err != nil {
t.Fatalf("error: %s", err)
}
@@ -395,7 +395,7 @@ func testLocksInWorkspace(t *testing.T, b1, b2 Backend, testForceUnlock bool, wo
t.Logf("TestBackend: testing state locking for %T", b1)
b2StateMgr, err := b2.StateMgr(t.Context(), DefaultStateName)
b2StateMgr, err := b2.StateMgr(t.Context(), workspace)
if err != nil {
t.Fatalf("error: %s", err)
}
@@ -423,7 +423,7 @@ func testLocksInWorkspace(t *testing.T, b1, b2 Backend, testForceUnlock bool, wo
// Make sure we can still get the statemgr.Full from another instance even
// when locked. This should only happen when a state is loaded via the
// backend, and as a remote state.
_, err = b2.StateMgr(t.Context(), DefaultStateName)
_, err = b2.StateMgr(t.Context(), workspace)
if err != nil {
t.Errorf("failed to read locked state from another backend instance: %s", err)
}