feat: improved tests

This commit is contained in:
theexiile1305 2024-10-09 14:43:43 +02:00
parent 2c2ee4c1fb
commit 6ea0974156
No known key found for this signature in database
GPG key ID: A1BDDE98F2BF6E40
3 changed files with 27 additions and 0 deletions

View file

@ -174,3 +174,8 @@ func (c ContentType) String() string {
func (e Encoding) String() string {
return string(e)
}
// String is a standard method to convert an MIMEType into a printable format
func (e MIMEType) String() string {
return string(e)
}

View file

@ -126,3 +126,24 @@ func TestCharset_String(t *testing.T) {
})
}
}
// TestContentType_String tests the mime type method of the MIMEType object
func TestMimeType_String(t *testing.T) {
tests := []struct {
mt MIMEType
want string
}{
{MIMEAlternative, "alternative"},
{MIMEMixed, "mixed"},
{MIMERelated, "related"},
{MIMESMime, `signed; protocol="application/pkcs7-signature"; micalg=sha-256`},
}
for _, tt := range tests {
t.Run(tt.mt.String(), func(t *testing.T) {
if tt.mt.String() != tt.want {
t.Errorf("wrong string for mime type returned. Expected: %s, got: %s",
tt.want, tt.mt.String())
}
})
}
}

View file

@ -10,6 +10,7 @@ const (
keyFilePath = "dummy-child-key.pem"
)
// getDummyCertificate loads a certificate and a private key form local disk for testing purposes
func getDummyCertificate() (*tls.Certificate, error) {
keyPair, err := tls.LoadX509KeyPair(certFilePath, keyFilePath)
if err != nil {