Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: more comments in helpers.go #366

Merged
merged 1 commit into from
Jan 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ import (
// `testdata/` and not absolute file paths.
//
// Important: TestLint is only appropriate for unit tests. It will panic if the
// lintName is not known or if the testCertFilename can not be loaded.
// lintName is not known or if the testCertFilename can not be loaded, or if the
// lint result is nil.
func TestLint(lintName string, testCertFilename string) *lint.LintResult {
return TestLintCert(lintName, ReadTestCert(testCertFilename))
}

// TestLintCert executes a lint with the given name against an already parsed
// certificate. This is useful when a unit test reads a certificate from disk
// and then mutates it in some way before trying to lint it.
//
// Important: TestLintCert is only appropriate for unit tests. It will panic if
// the lintName is not known or if the lint result is nil.
func TestLintCert(lintName string, cert *x509.Certificate) *lint.LintResult {
// NOTE(@cpu): Once the `lint.Lints` is not exported this will have to be
// NOTE(@cpu): Once `lint.Lints` is not exported this will have to be
// changed, likely to use a function like `lint.LintByName`. For now use the
// exported map directly to consolidate access to this one function instead of
// many individual lint unit tests.
Expand Down