File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "testing"
5+ )
6+
7+ func TestContains (t * testing.T ) {
8+ env := map [string ]string {
9+ "PORT" : "1234" ,
10+ }
11+
12+ if ! contains (env , "PORT" ) {
13+ t .Fail ()
14+ }
15+
16+ if contains (env , "MISSING" ) {
17+ t .Fail ()
18+ }
19+ }
20+
21+ func TestGroupByExitingKey (t * testing.T ) {
22+ containers := []* RuntimeContainer {
23+ & RuntimeContainer {
24+ Env : map [string ]string {
25+ "VIRTUAL_HOST" : "demo1.localhost" ,
26+ },
27+ ID : "1" ,
28+ },
29+ & RuntimeContainer {
30+ Env : map [string ]string {
31+ "VIRTUAL_HOST" : "demo1.localhost" ,
32+ },
33+ ID : "2" ,
34+ },
35+ & RuntimeContainer {
36+ Env : map [string ]string {
37+ "VIRTUAL_HOST" : "demo2.localhost" ,
38+ },
39+ ID : "3" ,
40+ },
41+ }
42+
43+ groups := groupBy (containers , "Env.VIRTUAL_HOST" )
44+ if len (groups ) != 2 {
45+ t .Fail ()
46+ }
47+
48+ if len (groups ["demo1.localhost" ]) != 2 {
49+ t .Fail ()
50+ }
51+
52+ if len (groups ["demo2.localhost" ]) != 1 {
53+ t .Fail ()
54+ }
55+ if groups ["demo2.localhost" ][0 ].ID != "3" {
56+ t .Fail ()
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments