Adds unit test for LoadCert

This commit is contained in:
Daniel 2016-11-26 17:49:34 -05:00
parent 4c1aa631ef
commit b66b54701e
No known key found for this signature in database
GPG Key ID: 08FB2BFC470E75B4
2 changed files with 37 additions and 7 deletions

View File

@ -49,13 +49,13 @@ github.com/letsencrypt/boulder/cmd/shell.go:147.4,147.46 1 0
github.com/letsencrypt/boulder/cmd/shell.go:150.4,153.46 4 0
github.com/letsencrypt/boulder/cmd/shell.go:144.31,146.5 1 0
github.com/letsencrypt/boulder/cmd/shell.go:147.46,149.5 1 0
github.com/letsencrypt/boulder/cmd/shell.go:168.53,169.16 1 0
github.com/letsencrypt/boulder/cmd/shell.go:173.2,174.16 2 0
github.com/letsencrypt/boulder/cmd/shell.go:178.2,179.49 2 0
github.com/letsencrypt/boulder/cmd/shell.go:184.2,185.8 2 0
github.com/letsencrypt/boulder/cmd/shell.go:169.16,172.3 2 0
github.com/letsencrypt/boulder/cmd/shell.go:174.16,176.3 1 0
github.com/letsencrypt/boulder/cmd/shell.go:179.49,182.3 2 0
github.com/letsencrypt/boulder/cmd/shell.go:168.53,169.16 1 4
github.com/letsencrypt/boulder/cmd/shell.go:173.2,174.16 2 3
github.com/letsencrypt/boulder/cmd/shell.go:178.2,179.49 2 2
github.com/letsencrypt/boulder/cmd/shell.go:184.2,185.8 2 1
github.com/letsencrypt/boulder/cmd/shell.go:169.16,172.3 2 1
github.com/letsencrypt/boulder/cmd/shell.go:174.16,176.3 1 1
github.com/letsencrypt/boulder/cmd/shell.go:179.49,182.3 2 1
github.com/letsencrypt/boulder/cmd/shell.go:193.31,196.16 3 0
github.com/letsencrypt/boulder/cmd/shell.go:199.2,200.16 2 0
github.com/letsencrypt/boulder/cmd/shell.go:203.2,205.16 3 0

View File

@ -130,3 +130,33 @@ func TestVersionString(t *testing.T) {
expected := fmt.Sprintf("Versions: test=(TestBuildID RightNow!) Golang=(%s) BuildHost=(Localhost)", runtime.Version())
test.AssertEquals(t, versionStr, expected)
}
func TestLoadCert(t *testing.T) {
testCases := []struct {
path string
expectedErr string
}{
{
"",
"Issuer certificate was not provided in config.",
},
{
"../does/not/exist",
"open ../does/not/exist: no such file or directory",
},
{
"../test/test-ca.key",
"Invalid certificate value returned",
},
}
for _, tc := range testCases {
_, err := LoadCert(tc.path)
test.AssertError(t, err, fmt.Sprintf("LoadCert(%q) did not error", tc.path))
test.AssertEquals(t, err.Error(), tc.expectedErr)
}
bytes, err := LoadCert("../test/test-ca.pem")
test.AssertNotError(t, err, "LoadCert(../test/test-ca.pem) errored")
test.AssertNotEquals(t, len(bytes), 0)
}