(t *testing.T)
| 196 | } |
| 197 | |
| 198 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…