Skip to content

Commit

Permalink
Improving test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jtyr committed Jul 22, 2018
1 parent d0e540a commit 4d28028
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/inputs/x509_cert/x509_cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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},
Expand Down

0 comments on commit 4d28028

Please sign in to comment.