Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
add test case for multiple TTL metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
rghetia committed Apr 23, 2019
1 parent 717a54e commit 953bf67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tag/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func Update(k Key, v string, mds ...Metadata) Mutator {
// value if k doesn't exist already. It mutates the value
// if k already exists.
// Metadata applies metadata to the tag. It is optional.
// Metadatas are applied in the order in which it is provided.
// If more than one metadata updates the same attribute then
// the update from the last metadata prevails.
func Upsert(k Key, v string, mds ...Metadata) Mutator {
return &mutator{
fn: func(m *Map) (*Map, error) {
Expand Down
12 changes: 12 additions & 0 deletions tag/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@ func TestNewMapWithMetadata(t *testing.T) {
want: makeTestTagMapWithMetadata(
tagContent{"4", ttlNoPropMd}),
},
{
name: "from non-existing; upsert with multiple-metadata",
initial: makeTestTagMapWithMetadata(
tagContent{"5", ttlNoPropMd}),
mods: []Mutator{
Upsert(k4, "4", WithTTL(TTLUnlimitedPropagation), WithTTL(TTLNoPropagation)),
Upsert(k5, "5", WithTTL(TTLNoPropagation), WithTTL(TTLUnlimitedPropagation)),
},
want: makeTestTagMapWithMetadata(
tagContent{"4", ttlNoPropMd},
tagContent{"5", ttlUnlimitedPropMd}),
},
{
name: "from empty; update invalid",
initial: nil,
Expand Down

0 comments on commit 953bf67

Please sign in to comment.