1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Rename int64Value to int64ValueOrZero.

Signed-off-by: Adria Casas <adriacasas88@gmail.com>
This commit is contained in:
Adria Casas 2015-04-23 09:40:23 +02:00
parent 91fb4d672a
commit a2c76912e0
3 changed files with 7 additions and 7 deletions

View file

@ -11,7 +11,7 @@ func boolValue(r *http.Request, k string) bool {
return !(s == "" || s == "0" || s == "no" || s == "false" || s == "none")
}
func int64Value(r *http.Request, k string) int64 {
func int64ValueOrZero(r *http.Request, k string) int64 {
val, err := strconv.ParseInt(r.FormValue(k), 10, 64)
if err != nil {
return 0

View file

@ -33,7 +33,7 @@ func TestBoolValue(t *testing.T) {
}
}
func TestInt64Value(t *testing.T) {
func TestInt64ValueOrZero(t *testing.T) {
cases := map[string]int64{
"": 0,
"asdf": 0,
@ -47,7 +47,7 @@ func TestInt64Value(t *testing.T) {
r, _ := http.NewRequest("POST", "", nil)
r.Form = v
a := int64Value(r, "test")
a := int64ValueOrZero(r, "test")
if a != e {
t.Fatalf("Value: %s, expected: %v, actual: %v", c, e, a)
}

View file

@ -1295,10 +1295,10 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht
buildConfig.ForceRemove = boolValue(r, "forcerm")
buildConfig.AuthConfig = authConfig
buildConfig.ConfigFile = configFile
buildConfig.MemorySwap = int64Value(r, "memswap")
buildConfig.Memory = int64Value(r, "memory")
buildConfig.CpuShares = int64Value(r, "cpushares")
buildConfig.CpuQuota = int64Value(r, "cpuquota")
buildConfig.MemorySwap = int64ValueOrZero(r, "memswap")
buildConfig.Memory = int64ValueOrZero(r, "memory")
buildConfig.CpuShares = int64ValueOrZero(r, "cpushares")
buildConfig.CpuQuota = int64ValueOrZero(r, "cpuquota")
buildConfig.CpuSetCpus = r.FormValue("cpusetcpus")
buildConfig.CpuSetMems = r.FormValue("cpusetmems")