Skip to content

Commit 2646911

Browse files
committed
Improve test
Use camel case style & assert the specific ECSDA type which should be the default that is generated.
1 parent 6f36acf commit 2646911

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

planetscale/dbutil/dbutil_test.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dbutil
33
import (
44
"context"
55
"crypto/ecdsa"
6-
"crypto/rsa"
76
"crypto/tls"
87
"crypto/x509"
98
"encoding/pem"
@@ -175,12 +174,15 @@ func parseCert(pemCert string) (*x509.Certificate, error) {
175174
return x509.ParseCertificate(bl.Bytes)
176175
}
177176

178-
func Test_generateKey(t *testing.T) {
179-
key, _ := generateKey()
180-
switch key.(type) {
181-
case *rsa.PrivateKey:
182-
case *ecdsa.PrivateKey:
183-
default:
184-
t.Fatal("generated key is not one of ECDSA or RSA private keys")
177+
func TestGenerateKey(t *testing.T) {
178+
key, err := generateKey()
179+
if err != nil {
180+
t.Fatal(err)
181+
}
182+
183+
_, ok := key.(*ecdsa.PrivateKey)
184+
185+
if !ok {
186+
t.Fatal("generated key is not an ECDSA private key")
185187
}
186188
}

0 commit comments

Comments
 (0)