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

Function TestInstanceList

internal/server/db/instances_test.go:198–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestInstanceList(t *testing.T) {
199 c, clusterCleanup := db.NewTestCluster(t)
200 defer clusterCleanup()
201
202 err := c.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
203 profile := cluster.Profile{
204 Project: "default",
205 Name: "profile1",
206 }
207
208 profileConfig := map[string]string{"a": "1"}
209 profileDevices := map[string]cluster.Device{
210 "root": {
211 Name: "root",
212 Type: cluster.TypeDisk,
213 Config: map[string]string{"b": "2"},
214 },
215 }
216
217 id, err := cluster.CreateProfile(ctx, tx.Tx(), profile)
218 if err != nil {
219 return err
220 }
221
222 err = cluster.CreateProfileConfig(ctx, tx.Tx(), id, profileConfig)
223 if err != nil {
224 return err
225 }
226
227 err = cluster.CreateProfileDevices(ctx, tx.Tx(), id, profileDevices)
228 if err != nil {
229 return err
230 }
231
232 container := cluster.Instance{
233 Project: "default",
234 Name: "c1",
235 Node: "none",
236 Type: instancetype.Container,
237 Architecture: 1,
238 Ephemeral: false,
239 Stateful: true,
240 }
241
242 id, err = cluster.CreateInstance(context.TODO(), tx.Tx(), container)
243 if err != nil {
244 return err
245 }
246
247 err = cluster.CreateInstanceConfig(context.TODO(), tx.Tx(), id, map[string]string{"c": "3"})
248 if err != nil {
249 return err
250 }
251
252 err = cluster.CreateInstanceDevices(context.TODO(), tx.Tx(), id, map[string]cluster.Device{"eth0": {Name: "eth0", Type: cluster.TypeNIC, Config: map[string]string{"d": "4"}}})
253 if err != nil {
254 return err
255 }

Callers

nothing calls this directly

Calls 15

NewTestClusterFunction · 0.92
CreateProfileFunction · 0.92
CreateProfileConfigFunction · 0.92
CreateProfileDevicesFunction · 0.92
CreateInstanceFunction · 0.92
CreateInstanceConfigFunction · 0.92
CreateInstanceDevicesFunction · 0.92
UpdateInstanceProfilesFunction · 0.92
ExpandInstanceConfigFunction · 0.92
ExpandInstanceDevicesFunction · 0.92
TxMethod · 0.80
InstanceListMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…