From 4d28028ba1664865791dd2cf7e9a2b9a8ff366f9 Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Sun, 22 Jul 2018 21:24:13 +0100 Subject: [PATCH] Improving test coverage --- plugins/inputs/x509_cert/x509_cert_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/inputs/x509_cert/x509_cert_test.go b/plugins/inputs/x509_cert/x509_cert_test.go index 113886b3d621a..2e9e2bdc84c68 100644 --- a/plugins/inputs/x509_cert/x509_cert_test.go +++ b/plugins/inputs/x509_cert/x509_cert_test.go @@ -24,6 +24,17 @@ func TestGatherRemote(t *testing.T) { t.Skip("Skipping network-dependent test in short mode.") } + tmpfile, err := ioutil.TempFile("", "example") + if err != nil { + t.Fatal(err) + } + + defer os.Remove(tmpfile.Name()) + + if _, err := tmpfile.Write([]byte(pki.ReadServerCert())); err != nil { + t.Fatal(err) + } + tests := []struct { server string timeout time.Duration @@ -34,6 +45,8 @@ func TestGatherRemote(t *testing.T) { }{ {server: ":99999", timeout: 0, close: false, unset: false, error: true}, {server: "", timeout: 5, close: false, unset: false, error: false}, + {server: "https://example.org:443", timeout: 5, close: false, unset: false, error: false}, + {server: "file://" + tmpfile.Name(), timeout: 5, close: false, unset: false, error: false}, {server: "", timeout: 5, close: false, unset: true, error: true}, {server: "", timeout: 0, close: true, unset: false, error: true}, {server: "", timeout: 5, close: false, unset: false, noshake: true, error: true},