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

Side by Side Diff: state/state_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/state.go ('k') | no next file » | 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 "net/url" 8 "net/url"
9 "sort" 9 "sort"
10 "strconv" 10 "strconv"
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 _, err = s.State.AddNetwork("net42", "invalid", 0) 989 _, err = s.State.AddNetwork("net42", "invalid", 0)
990 expectErr = `cannot add network "net42": invalid CIDR address: invalid` 990 expectErr = `cannot add network "net42": invalid CIDR address: invalid`
991 c.Assert(err, gc.ErrorMatches, expectErr) 991 c.Assert(err, gc.ErrorMatches, expectErr)
992 _, err = s.State.AddNetwork("net69", "0.3.1.0/30", -1) 992 _, err = s.State.AddNetwork("net69", "0.3.1.0/30", -1)
993 expectErr = `cannot add network "net69": invalid VLAN tag -1: must be be tween 0 and 4094` 993 expectErr = `cannot add network "net69": invalid VLAN tag -1: must be be tween 0 and 4094`
994 c.Assert(err, gc.ErrorMatches, expectErr) 994 c.Assert(err, gc.ErrorMatches, expectErr)
995 _, err = s.State.AddNetwork("net69", "0.3.1.0/30", 9999) 995 _, err = s.State.AddNetwork("net69", "0.3.1.0/30", 9999)
996 expectErr = `cannot add network "net69": invalid VLAN tag 9999: must be between 0 and 4094` 996 expectErr = `cannot add network "net69": invalid VLAN tag 9999: must be between 0 and 4094`
997 c.Assert(err, gc.ErrorMatches, expectErr) 997 c.Assert(err, gc.ErrorMatches, expectErr)
998 _, err = s.State.AddNetwork("net1", "0.1.2.0/24", 0) 998 _, err = s.State.AddNetwork("net1", "0.1.2.0/24", 0)
999 » expectErr = `cannot add network "net1": already exists` 999 » expectErr = `network net1 already exists`
1000 c.Assert(err, gc.ErrorMatches, expectErr) 1000 c.Assert(err, gc.ErrorMatches, expectErr)
1001 c.Assert(err, jc.Satisfies, errors.IsAlreadyExistsError)
1001 } 1002 }
1002 1003
1003 func (s *StateSuite) TestAddService(c *gc.C) { 1004 func (s *StateSuite) TestAddService(c *gc.C) {
1004 charm := s.AddTestingCharm(c, "dummy") 1005 charm := s.AddTestingCharm(c, "dummy")
1005 _, err := s.State.AddService("haha/borken", "user-admin", charm, nil, ni l) 1006 _, err := s.State.AddService("haha/borken", "user-admin", charm, nil, ni l)
1006 c.Assert(err, gc.ErrorMatches, `cannot add service "haha/borken": invali d name`) 1007 c.Assert(err, gc.ErrorMatches, `cannot add service "haha/borken": invali d name`)
1007 _, err = s.State.Service("haha/borken") 1008 _, err = s.State.Service("haha/borken")
1008 c.Assert(err, gc.ErrorMatches, `"haha/borken" is not a valid service nam e`) 1009 c.Assert(err, gc.ErrorMatches, `"haha/borken" is not a valid service nam e`)
1009 1010
1010 // set that a nil charm is handled correctly 1011 // set that a nil charm is handled correctly
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 Port: 99, 2993 Port: 99,
2993 }}}) 2994 }}})
2994 c.Assert(err, gc.IsNil) 2995 c.Assert(err, gc.IsNil)
2995 2996
2996 wc.AssertOneChange() 2997 wc.AssertOneChange()
2997 2998
2998 // Stop, check closed. 2999 // Stop, check closed.
2999 statetesting.AssertStop(c, w) 3000 statetesting.AssertStop(c, w)
3000 wc.AssertClosed() 3001 wc.AssertClosed()
3001 } 3002 }
OLDNEW
« no previous file with comments | « state/state.go ('k') | no next file » | no next file with comments »

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