Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

proof-go

Go SDK for proof -- capture visual evidence of test execution.

Thin wrapper around the proof CLI. If the binary isn't on PATH, it auto-downloads from GitHub Releases on first use.

Install

go get github.com/automazeio/proof-go

Usage

package main

import (
    "fmt"
    "github.com/automazeio/proof-go/proof"
)

func main() {
    p, err := proof.New(proof.Config{
        AppName:  "my-app",
        ProofDir: "./evidence",
    })
    if err != nil {
        panic(err)
    }

    rec, err := p.Capture(proof.CaptureOptions{
        Command: "go test ./... -v",
        Mode:    "terminal",
        Label:   "unit-tests",
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(rec.Path)     // /abs/path/unit-tests-143012.html
    fmt.Println(rec.Duration) // 4300
    fmt.Println(rec.ExitCode) // 0 (exit code of the wrapped command)

    reportPath, _ := p.Report(proof.ReportOptions{})
    fmt.Println(reportPath)
}

Gating on the result

Capture always records the run and returns the Recording — it does not return an error just because the wrapped command failed. Inspect ExitCode to gate:

rec, _ := p.Capture(proof.CaptureOptions{Command: "go test ./...", Mode: "terminal"})
p.Report(proof.ReportOptions{})
if rec.ExitCode != 0 {
    os.Exit(rec.ExitCode) // fail the run, keep the evidence
}

go test integration

func TestMain(m *testing.M) {
    p, _ := proof.New(proof.Config{
        AppName:  "my-service",
        ProofDir: "./evidence",
    })
    p.Capture(proof.CaptureOptions{
        Command: "go test ./... -v -count=1",
        Mode:    "terminal",
        Label:   "all-tests",
    })
    code := m.Run()
    p.Report(proof.ReportOptions{})
    os.Exit(code)
}

Binary resolution

  1. proof on PATH
  2. ~/.proof/bin/proof-<version> (cached from previous download)
  3. Auto-download from GitHub Releases (~100MB, one time)

Install the binary manually

curl -fsSL https://automaze.io/install/proof | sh

About

Go SDK for proof — capture visual evidence of test execution

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages