...

Source file src/github.com/aws/smithy-go/middleware/metadata_test.go

Documentation: github.com/aws/smithy-go/middleware

     1  package middleware
     2  
     3  import "testing"
     4  
     5  func TestMetadataClone(t *testing.T) {
     6  	original := map[interface{}]interface{}{
     7  		"abc": 123,
     8  		"efg": "hij",
     9  	}
    10  
    11  	var m Metadata
    12  	for k, v := range original {
    13  		m.Set(k, v)
    14  	}
    15  
    16  	o := m.Clone()
    17  	o.Set("unique", "value")
    18  	for k := range original {
    19  		if !o.Has(k) {
    20  			t.Errorf("expect %v to be in cloned metadata", k)
    21  		}
    22  	}
    23  
    24  	if !o.Has("unique") {
    25  		t.Errorf("expect cloned metadata to have new entry")
    26  	}
    27  	if m.Has("unique") {
    28  		t.Errorf("expect cloned metadata to not leak in to original")
    29  	}
    30  }
    31  

View as plain text