forked from docker/libcompose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomposable_test.go
47 lines (40 loc) · 981 Bytes
/
composable_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package lookup
import (
"testing"
"github.com/docker/libcompose/config"
)
type simpleEnvLookup struct {
value []string
}
func (l *simpleEnvLookup) Lookup(key string, config *config.ServiceConfig) []string {
return l.value
}
func TestComposableLookupWithoutAnyLookup(t *testing.T) {
envLookup := &ComposableEnvLookup{}
actuals := envLookup.Lookup("any", nil)
if len(actuals) != 0 {
t.Fatalf("expected an empty slice, got %v", actuals)
}
}
func TestComposableLookupReturnsTheLastValue(t *testing.T) {
envLookup1 := &simpleEnvLookup{
value: []string{"value=1"},
}
envLookup2 := &simpleEnvLookup{
value: []string{"value=2"},
}
envLookup := &ComposableEnvLookup{
[]config.EnvironmentLookup{
envLookup1,
envLookup2,
},
}
validateLookup(t, "value=2", envLookup.Lookup("value", nil))
envLookup = &ComposableEnvLookup{
[]config.EnvironmentLookup{
envLookup2,
envLookup1,
},
}
validateLookup(t, "value=1", envLookup.Lookup("value", nil))
}