mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
This patch adds some tooling and scripts to generate test coverage information. Unfortunately, this involves some hacks as Go does not have support for generating coverage-enabled binaries, or merging coverage reports; but overall it's not very intrusive.
39 lines
594 B
Go
39 lines
594 B
Go
// CLI used for testing the dovecot authentication package.
|
|
//
|
|
// NOT for production use.
|
|
// +build !coverage
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"blitiri.com.ar/go/chasquid/internal/dovecot"
|
|
)
|
|
|
|
func main() {
|
|
a := dovecot.NewAuth(os.Args[1]+"-userdb", os.Args[1]+"-client")
|
|
|
|
var ok bool
|
|
var err error
|
|
|
|
switch os.Args[2] {
|
|
case "exists":
|
|
ok, err = a.Exists(os.Args[3])
|
|
case "auth":
|
|
ok, err = a.Authenticate(os.Args[3], os.Args[4])
|
|
default:
|
|
fmt.Printf("unknown subcommand\n")
|
|
os.Exit(1)
|
|
}
|
|
|
|
if ok {
|
|
fmt.Printf("yes\n")
|
|
return
|
|
}
|
|
|
|
fmt.Printf("no: %v\n", err)
|
|
os.Exit(1)
|
|
}
|