mirror of https://github.com/docker/docs.git
engine.Env: comments and tests for Get()
Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
parent
2d1c8bd786
commit
6e0bc06018
|
@ -11,8 +11,10 @@ import (
|
||||||
|
|
||||||
type Env []string
|
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) {
|
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 {
|
for _, kv := range *env {
|
||||||
if strings.Index(kv, "=") == -1 {
|
if strings.Index(kv, "=") == -1 {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -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) {
|
func TestNewJob(t *testing.T) {
|
||||||
job := mkJob(t, "dummy", "--level=awesome")
|
job := mkJob(t, "dummy", "--level=awesome")
|
||||||
if job.Name != "dummy" {
|
if job.Name != "dummy" {
|
||||||
|
|
Loading…
Reference in New Issue