MCPcopy
hub / github.com/lxc/incus / NewTestClusterTx

Function NewTestClusterTx

internal/server/db/testing.go:84–100  ·  view source on GitHub ↗

NewTestClusterTx returns a fresh ClusterTx object, along with a function that can be called to cleanup state when done with it.

(t *testing.T)

Source from the content-addressed store, hash-verified

82// NewTestClusterTx returns a fresh ClusterTx object, along with a function that can
83// be called to cleanup state when done with it.
84func NewTestClusterTx(t *testing.T) (*ClusterTx, func()) {
85 cluster, clusterCleanup := NewTestCluster(t)
86
87 var err error
88
89 clusterTx := &ClusterTx{nodeID: cluster.nodeID}
90 clusterTx.tx, err = cluster.db.Begin()
91 require.NoError(t, err)
92
93 cleanup := func() {
94 err := clusterTx.tx.Commit()
95 require.NoError(t, err)
96 clusterCleanup()
97 }
98
99 return clusterTx, cleanup
100}
101
102// NewTestCowsqlServer creates a new test cowsql server.
103//

Calls 3

NewTestClusterFunction · 0.85
BeginMethod · 0.80
CommitMethod · 0.65

Used in the wild real call sites across dependent graphs

searching dependent graphs…