Skip to content

Commit

Permalink
add unit tests to increase test coverage (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahvita authored Nov 29, 2023
1 parent a2a3b0b commit 3280c19
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
31 changes: 31 additions & 0 deletions auth/option_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package auth

import (
"testing"
"reflect"
smithy "github.com/aws/smithy-go"
)

func TestAuthOptions(t *testing.T) {
var ip smithy.Properties
ip.Set("foo", "bar")

var sp smithy.Properties
sp.Set("foo", "bar")

expected := []*Option{
&Option{
SchemeID: "fakeSchemeID",
IdentityProperties: ip,
SignerProperties: sp,
},
}

var m smithy.Properties
SetAuthOptions(&m, expected)
actual, _ := GetAuthOptions(&m)

if !reflect.DeepEqual(expected, actual) {
t.Errorf("Expect AuthOptions to be equivalent %v != %v", expected, actual)
}
}
11 changes: 10 additions & 1 deletion properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ func TestProperties(t *testing.T) {
t.Errorf("expect key / value properties to be equivalent: %v / %v", k, v)
}
}
}

var n Properties
n.SetAll(&m)
for k, v := range original {
if n.Get(k) != v {
t.Errorf("expect key / value properties to be equivalent: %v / %v", k, v)
}
}

}
74 changes: 74 additions & 0 deletions transport/http/properties_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package http

import (
"testing"
"reflect"
smithy "github.com/aws/smithy-go"
)


func TestSigV4SigningName(t *testing.T) {
expected := "foo"
var m smithy.Properties
SetSigV4SigningName(&m, expected)
actual, _ := GetSigV4SigningName(&m)

if expected != actual {
t.Errorf("Expect SigV4SigningName to be equivalent %s != %s", expected, actual)
}
}

func TestSigV4SigningRegion(t *testing.T) {
expected := "foo"
var m smithy.Properties
SetSigV4SigningRegion(&m, expected)
actual, _ := GetSigV4SigningRegion(&m)

if expected != actual {
t.Errorf("Expect SigV4SigningRegion to be equivalent %s != %s", expected, actual)
}
}

func TestSigV4ASigningName(t *testing.T) {
expected := "foo"
var m smithy.Properties
SetSigV4ASigningName(&m, expected)
actual, _ := GetSigV4ASigningName(&m)

if expected != actual {
t.Errorf("Expect SigV4ASigningName to be equivalent %s != %s", expected, actual)
}
}

func TestSigV4SigningRegions(t *testing.T) {
expected := []string{"foo", "bar"}
var m smithy.Properties
SetSigV4ASigningRegions(&m, expected)
actual, _ := GetSigV4ASigningRegions(&m)

if !reflect.DeepEqual(expected, actual) {
t.Errorf("Expect SigV4ASigningRegions to be equivalent %v != %v", expected, actual)
}
}

func TestUnsignedPayload(t *testing.T) {
expected := true
var m smithy.Properties
SetIsUnsignedPayload(&m, expected)
actual, _ := GetIsUnsignedPayload(&m)

if expected != actual {
t.Errorf("Expect IsUnsignedPayload to be equivalent %v != %v", expected, actual)
}
}

func TestDisableDoubleEncoding(t *testing.T) {
expected := true
var m smithy.Properties
SetDisableDoubleEncoding(&m, expected)
actual, _ := GetDisableDoubleEncoding(&m)

if expected != actual {
t.Errorf("Expect DisableDoubleEncoding to be equivalent %v != %v", expected, actual)
}
}

0 comments on commit 3280c19

Please sign in to comment.