LEFT | RIGHT |
1 // Copyright 2011, 2012, 2013 Canonical Ltd. | 1 // Copyright 2011, 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 jujutest | 4 package jujutest |
5 | 5 |
6 import ( | 6 import ( |
7 "bytes" | 7 "bytes" |
8 "fmt" | 8 "fmt" |
9 "io" | 9 "io" |
10 "io/ioutil" | 10 "io/ioutil" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 func (t *LiveTests) TestPrechecker(c *gc.C) { | 134 func (t *LiveTests) TestPrechecker(c *gc.C) { |
135 // Providers may implement Prechecker. If they do, then they should | 135 // Providers may implement Prechecker. If they do, then they should |
136 // return nil for empty constraints (excluding the null provider). | 136 // return nil for empty constraints (excluding the null provider). |
137 prechecker, ok := t.Env.(environs.Prechecker) | 137 prechecker, ok := t.Env.(environs.Prechecker) |
138 if !ok { | 138 if !ok { |
139 return | 139 return |
140 } | 140 } |
141 | 141 |
142 const series = "precise" | 142 const series = "precise" |
143 var cons constraints.Value | 143 var cons constraints.Value |
144 » c.Check(prechecker.PrecheckCreateMachine(series, cons), gc.IsNil) | 144 » c.Check(prechecker.PrecheckInstance(series, cons), gc.IsNil) |
145 | 145 |
146 » inst, _ := testing.StartInstance(c, t.Env, "0") | 146 » err := prechecker.PrecheckContainer(series, instance.LXC) |
147 » c.Assert(inst, gc.NotNil) | |
148 » container := instance.LXC | |
149 » cons.Container = &container | |
150 » err := prechecker.PrecheckCreateContainer(series, cons, inst) | |
151 // If err is nil, that is fine, some providers support containers. | 147 // If err is nil, that is fine, some providers support containers. |
152 if err != nil { | 148 if err != nil { |
153 // But for ones that don't, they should have a standard error fo
rmat. | 149 // But for ones that don't, they should have a standard error fo
rmat. |
154 c.Check(err, gc.ErrorMatches, ".*provider does not support conta
iners") | 150 c.Check(err, gc.ErrorMatches, ".*provider does not support conta
iners") |
155 c.Check(err, jc.Satisfies, coreerrors.IsContainersUnsupported) | 151 c.Check(err, jc.Satisfies, coreerrors.IsContainersUnsupported) |
156 } | 152 } |
157 } | 153 } |
158 | 154 |
159 // TestStartStop is similar to Tests.TestStartStop except | 155 // TestStartStop is similar to Tests.TestStartStop except |
160 // that it does not assume a pristine environment. | 156 // that it does not assume a pristine environment. |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 return err | 920 return err |
925 } | 921 } |
926 var buf bytes.Buffer | 922 var buf bytes.Buffer |
927 _, err = io.Copy(&buf, rc) | 923 _, err = io.Copy(&buf, rc) |
928 rc.Close() | 924 rc.Close() |
929 if err != nil { | 925 if err != nil { |
930 return err | 926 return err |
931 } | 927 } |
932 return target.Put(targetPath, &buf, int64(buf.Len())) | 928 return target.Put(targetPath, &buf, int64(buf.Len())) |
933 } | 929 } |
LEFT | RIGHT |