Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(35)

Side by Side Diff: state/machine_test.go

Issue 85380043: state;api: Allow adding existing networks/NICs (Closed)
Patch Set: Created 9 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « state/machine.go ('k') | state/state.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package state_test 4 package state_test
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "sort" 8 "sort"
9 9
10 jc "github.com/juju/testing/checkers" 10 jc "github.com/juju/testing/checkers"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 errorPrefix := fmt.Sprintf("cannot add network interface to machine %s: ", machine.Id()) 489 errorPrefix := fmt.Sprintf("cannot add network interface to machine %s: ", machine.Id())
490 _, err = machine.AddNetworkInterface("invalid", "eth0", "net1") 490 _, err = machine.AddNetworkInterface("invalid", "eth0", "net1")
491 expectErr := errorPrefix + "invalid MAC address: invalid" 491 expectErr := errorPrefix + "invalid MAC address: invalid"
492 c.Assert(err, gc.ErrorMatches, expectErr) 492 c.Assert(err, gc.ErrorMatches, expectErr)
493 493
494 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:ff", "", "net1") 494 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:ff", "", "net1")
495 expectErr = errorPrefix + "interface name must be not empty" 495 expectErr = errorPrefix + "interface name must be not empty"
496 c.Assert(err, gc.ErrorMatches, expectErr) 496 c.Assert(err, gc.ErrorMatches, expectErr)
497 497
498 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:f0", "eth2", "net1" ) 498 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:f0", "eth2", "net1" )
499 » expectErr = errorPrefix + `interface with MAC address "aa:bb:cc:dd:ee:f0 " already exists` 499 » expectErr = `interface with MAC address aa:bb:cc:dd:ee:f0 already exists `
500 c.Assert(err, gc.ErrorMatches, expectErr) 500 c.Assert(err, gc.ErrorMatches, expectErr)
501 c.Assert(err, jc.Satisfies, errors.IsAlreadyExistsError)
501 502
502 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:f0", "eth2", "inval id") 503 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:f0", "eth2", "inval id")
503 expectErr = errorPrefix + `network "invalid" not found` 504 expectErr = errorPrefix + `network "invalid" not found`
504 c.Assert(err, gc.ErrorMatches, expectErr) 505 c.Assert(err, gc.ErrorMatches, expectErr)
505 506
506 err = machine.SetProvisioned("i-am", "fake_nonce", nil) 507 err = machine.SetProvisioned("i-am", "fake_nonce", nil)
507 c.Assert(err, gc.IsNil) 508 c.Assert(err, gc.IsNil)
508 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:ff", "eth2", "net1" ) 509 _, err = machine.AddNetworkInterface("aa:bb:cc:dd:ee:ff", "eth2", "net1" )
509 expectErr = errorPrefix + "machine already provisioned: dynamic network interfaces not currently supported" 510 expectErr = errorPrefix + "machine already provisioned: dynamic network interfaces not currently supported"
510 c.Assert(err, gc.ErrorMatches, expectErr) 511 c.Assert(err, gc.ErrorMatches, expectErr)
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 err = container.Refresh() 1544 err = container.Refresh()
1544 c.Assert(err, gc.IsNil) 1545 c.Assert(err, gc.IsNil)
1545 status, info, data, err := container.Status() 1546 status, info, data, err := container.Status()
1546 c.Assert(err, gc.IsNil) 1547 c.Assert(err, gc.IsNil)
1547 c.Assert(status, gc.Equals, params.StatusError) 1548 c.Assert(status, gc.Equals, params.StatusError)
1548 c.Assert(info, gc.Equals, "unsupported container") 1549 c.Assert(info, gc.Equals, "unsupported container")
1549 containerType := state.ContainerTypeFromId(container.Id()) 1550 containerType := state.ContainerTypeFromId(container.Id())
1550 c.Assert(data, gc.DeepEquals, params.StatusData{"type": string(c ontainerType)}) 1551 c.Assert(data, gc.DeepEquals, params.StatusData{"type": string(c ontainerType)})
1551 } 1552 }
1552 } 1553 }
OLDNEW
« no previous file with comments | « state/machine.go ('k') | state/state.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b