Merge pull request #7984 from vbatts/vbatts-engine_env_comments

engine.Env: comments and tests for Get()
Upstream-commit: e550fc532cd965ff109794452f0530fa4a1db232
Component: engine
This commit is contained in:
Jessie Frazelle
2014-09-11 10:19:58 -07:00
2 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -11,8 +11,10 @@ import (
type Env []string
// Get returns the last value associated with the given key. If there are no
// values associated with the key, Get returns the empty string.
func (env *Env) Get(key string) (value string) {
// FIXME: use Map()
// not using Map() because of the extra allocations https://github.com/docker/docker/pull/7488#issuecomment-51638315
for _, kv := range *env {
if strings.Index(kv, "=") == -1 {
continue
+12
View File
@@ -36,6 +36,18 @@ func TestEnvLenDup(t *testing.T) {
}
}
func TestEnvGetDup(t *testing.T) {
env := &Env{
"foo=bar",
"foo=baz",
"foo=bif",
}
expected := "bif"
if v := env.Get("foo"); v != expected {
t.Fatalf("expect %q, got %q", expected, v)
}
}
func TestNewJob(t *testing.T) {
job := mkJob(t, "dummy", "--level=awesome")
if job.Name != "dummy" {