2026-10-10 14:03:57 +00:00
package main
import (
"os/exec"
"path/filepath"
"strings"
"testing"
)
func TestNativeCheckFromChildUsesRootProfileAndSuite ( t * testing . T ) {
binary := buildWorkflowCLI ( t , cliRepositoryRoot ( t ) )
repository := newCLIRepository ( t )
writeRepositoryFile ( t , repository , "candidate_test.go" , "package candidate\nimport \"testing\"\nfunc TestFixture(t *testing.T) { t.Fatal(\"root suite failure\") }\n" )
writeRepositoryFile ( t , repository , "releasekit.json" , ` { "product":"Example Product"} ` )
writeRepositoryFile ( t , repository , "apps/widget/go.mod" , "module example.com/widget\n\ngo 1.26.0\n" )
writeRepositoryFile ( t , repository , "apps/widget/widget_test.go" , "package widget\nimport \"testing\"\nfunc TestWidget(t *testing.T) {}\n" )
cliGitRun ( t , repository , "add" , "." )
cliGitRun ( t , repository , "commit" , "-m" , "Add failing root and passing child" )
command := exec . Command ( binary , "check" , "v1.2.3" )
command . Dir = filepath . Join ( repository , "apps" , "widget" )
output , err := command . CombinedOutput ( )
if exit , ok := err . ( * exec . ExitError ) ; ! ok || exit . ExitCode ( ) != 1 || ! strings . Contains ( string ( output ) , "root suite failure" ) || ! strings . Contains ( string ( output ) , "module=example.com/cli-candidate" ) {
t . Fatalf ( "child invocation error = %v, output = %s" , err , output )
}
}
2026-10-10 14:05:39 +00:00
func TestNativeBuildClassifiesInvalidVersionBeforeSourceAccess ( t * testing . T ) {
binary := buildWorkflowCLI ( t , cliRepositoryRoot ( t ) )
command := exec . Command ( binary , "build" , "--repo" , filepath . Join ( t . TempDir ( ) , "absent" ) , "bad-version" )
output , err := command . CombinedOutput ( )
if exit , ok := err . ( * exec . ExitError ) ; ! ok || exit . ExitCode ( ) != 2 || ! strings . Contains ( string ( output ) , "stable vMAJOR.MINOR.PATCH" ) {
t . Fatalf ( "invalid build error = %v, output = %s" , err , output )
}
}