mirror of https://github.com/k3d-io/k3d
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
937 B
41 lines
937 B
package test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/magefile/mage/sh"
|
|
)
|
|
|
|
// Unit run all unit tests
|
|
func Unit() error {
|
|
fmt.Println("Running Tests...")
|
|
return sh.RunV("go", "test")
|
|
}
|
|
|
|
// Build run a test build to confirm no compilation errors
|
|
func Build() error {
|
|
fmt.Println("Running Build...")
|
|
return sh.RunV("go", "build", "-tags", "test")
|
|
}
|
|
|
|
// Coverage run all unit tests and output coverage
|
|
func Coverage() error {
|
|
fmt.Println("Running Tests with Coverage...")
|
|
return sh.RunV("go", "test", "-v", "-coverprofile=coverage.txt", ".")
|
|
}
|
|
|
|
// HTML display the html coverage report from the cover tool
|
|
func HTML() error {
|
|
if err := Coverage(); err != nil {
|
|
return err
|
|
}
|
|
return sh.RunV("go", "tool", "cover", "-html", "coverage.txt")
|
|
}
|
|
|
|
// Func display the func coverage report from the cover tool
|
|
func Func() error {
|
|
if err := Coverage(); err != nil {
|
|
return err
|
|
}
|
|
return sh.RunV("go", "tool", "cover", "-func", "coverage.txt")
|
|
}
|
|
|