40 lines
979 B
Go
40 lines
979 B
Go
package app
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateLocalBundle(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
err := Validate(context.Background(), ValidateOptions{
|
|
Path: filepath.Join("..", "bundle", "testdata", "valid_bundle"),
|
|
Stdout: &stdout,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("Validate() error = %v", err)
|
|
}
|
|
if got, want := stdout.String(), "Validated 1 bundle(s)\n"; got != want {
|
|
t.Fatalf("stdout = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestValidateExampleSourceBundle(t *testing.T) {
|
|
err := Validate(context.Background(), ValidateOptions{
|
|
Path: filepath.Join("..", "..", "examples", "source-bundle"),
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("Validate() example error = %v", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateRequiresPath(t *testing.T) {
|
|
err := Validate(context.Background(), ValidateOptions{})
|
|
if err == nil || !strings.Contains(err.Error(), "requires a path") {
|
|
t.Fatalf("Validate() error = %v, want required path", err)
|
|
}
|
|
}
|