From 6284b0748bcaa9b827dc8a87dcad2951b13bf66c Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 19 May 2024 13:59:38 -0700 Subject: [PATCH] improving code coverage --- codecov.yml | 2 +- gencerts_test.go | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/codecov.yml b/codecov.yml index e748a6a..318fcae 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,5 +2,5 @@ coverage: status: project: default: - target: 75% + target: 70% threshold: 10% diff --git a/gencerts_test.go b/gencerts_test.go index 0dc187f..90a1e50 100644 --- a/gencerts_test.go +++ b/gencerts_test.go @@ -7,10 +7,38 @@ import ( ) func TestGeneratingCerts(t *testing.T) { - _, _, err := GenerateCerts() - if err != nil { - t.Errorf("Error while generating certificates - %s", err) - } + t.Run("No Domain", func(t *testing.T) { + cert, key, err := GenerateCerts() + if err != nil { + t.Errorf("Error while generating certificates - %s", err) + } + + if len(cert) == 0 || len(key) == 0 { + t.Errorf("Cert %d or Key %d is empty", len(cert), len(key)) + } + }) + + t.Run("With Domain", func(t *testing.T) { + cert, key, err := GenerateCerts("example.com") + if err != nil { + t.Errorf("Error while generating certificates - %s", err) + } + + if len(cert) == 0 || len(key) == 0 { + t.Errorf("Cert %d or Key %d is empty", len(cert), len(key)) + } + }) + + t.Run("With Many Domains", func(t *testing.T) { + cert, key, err := GenerateCerts("example.com", "example.org", "example.net") + if err != nil { + t.Errorf("Error while generating certificates - %s", err) + } + + if len(cert) == 0 || len(key) == 0 { + t.Errorf("Cert %d or Key %d is empty", len(cert), len(key)) + } + }) } func TestGeneratingCertsToFile(t *testing.T) {