From d23b4052c0866698b14ac13ac98581d9f5440a9b Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sun, 11 Mar 2018 19:38:27 +0100 Subject: revamp the Headers API 1. Move common methods of AccountHeaders, ContainerHeaders, ObjectHeaders into a base type Headers. 2. Fold Headers into RequestOptions to remove one of the two optional arguments on request methods. The new Headers.ToOpts() method offers a nice experience for users passing Headers to request methods. The Update() methods keep the explicit Headers argument since the Headers argument is not optional there. The only downside is that we lose a bit of type-safety because RequestOptions takes any Headers instance, so e.g. ContainerHeaders could be passed to Object.Upload(). I believe the benefits outweigh this problem. --- tests/account_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/account_test.go') diff --git a/tests/account_test.go b/tests/account_test.go index 310d4ce..2885bfa 100644 --- a/tests/account_test.go +++ b/tests/account_test.go @@ -41,7 +41,7 @@ func TestAccountBasic(t *testing.T) { func TestAccountMetadata(t *testing.T) { testWithAccount(t, func(a *schwift.Account) { //test creating some metadata - hdr := make(schwift.AccountHeaders) + hdr := schwift.NewAccountHeaders() hdr.Metadata().Set("schwift-test1", "first") hdr.Metadata().Set("schwift-test2", "second") err := a.Update(hdr, nil) @@ -57,7 +57,7 @@ func TestAccountMetadata(t *testing.T) { expectString(t, hdr.Metadata().Get("schwift-test2"), "second") //test deleting some metadata - hdr = make(schwift.AccountHeaders) + hdr = schwift.NewAccountHeaders() hdr.Metadata().Clear("schwift-test1") err = a.Update(hdr, nil) if !expectSuccess(t, err) { @@ -72,7 +72,7 @@ func TestAccountMetadata(t *testing.T) { expectString(t, hdr.Metadata().Get("schwift-test2"), "second") //test updating some metadata - hdr = make(schwift.AccountHeaders) + hdr = schwift.NewAccountHeaders() hdr.Metadata().Set("schwift-test1", "will not be set") hdr.Metadata().Del("schwift-test1") hdr.Metadata().Set("schwift-test2", "changed") -- cgit v1.2.3