-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from buildkite/support-meta-data-keys
Support listing meta-data keys
- Loading branch information
Showing
3 changed files
with
144 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package local | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestOrderedMapStoreAndLoad(t *testing.T) { | ||
om := newOrderedMap() | ||
om.Store("a", true) | ||
om.Store("b", false) | ||
om.Store("c", 24) | ||
om.Store("a", 32) | ||
|
||
for _, val := range []string{"a", "b", "c"} { | ||
if om.Contains(val) == false { | ||
t.Fatalf("Expected to contain %s", val) | ||
} | ||
} | ||
|
||
if om.Contains("nope") == true { | ||
t.Fatalf("Unexpected to contain nope") | ||
} | ||
|
||
val, ok := om.Load("a") | ||
if !ok { | ||
t.Fatalf("Not ok") | ||
} | ||
if val != 32 { | ||
t.Fatalf("Bad %v (%T)", val, val) | ||
} | ||
|
||
val, ok = om.Load("b") | ||
if !ok { | ||
t.Fatalf("Not ok") | ||
} | ||
if val != false { | ||
t.Fatalf("Bad %v (%T)", val, val) | ||
} | ||
|
||
val, ok = om.Load("c") | ||
if !ok { | ||
t.Fatalf("Not ok") | ||
} | ||
if val != 24 { | ||
t.Fatalf("Bad %v (%T)", val, val) | ||
} | ||
} | ||
|
||
func TestOrderedMapKeys(t *testing.T) { | ||
om := newOrderedMap() | ||
om.Store("a", true) | ||
om.Store("b", false) | ||
om.Store("c", 24) | ||
om.Store("a", 32) | ||
|
||
keys := om.Keys() | ||
|
||
if !reflect.DeepEqual(keys, []string{"a", "b", "c"}) { | ||
t.Fatalf("Unexpected keys: %#v", keys) | ||
} | ||
} |