feat: unify installation model catalog
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
// Catches --build being ignored, which would run stale images after a checkout update.
|
||||
func TestStartBuildsBeforeStartingAndCheckingHealth(t *testing.T) {
|
||||
stubModelProjection(t, nil)
|
||||
runner := &recordingRunner{}
|
||||
installation := testInstallation()
|
||||
|
||||
@@ -26,6 +27,7 @@ func TestStartBuildsBeforeStartingAndCheckingHealth(t *testing.T) {
|
||||
|
||||
// Catches a normal start unnecessarily rebuilding images.
|
||||
func TestStartSkipsBuildUnlessRequested(t *testing.T) {
|
||||
stubModelProjection(t, nil)
|
||||
runner := &recordingRunner{}
|
||||
installation := testInstallation()
|
||||
|
||||
@@ -38,6 +40,7 @@ func TestStartSkipsBuildUnlessRequested(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartRefusesProjectedAuthenticationBeforeComposeWhenNotReady(t *testing.T) {
|
||||
stubModelProjection(t, nil)
|
||||
for _, state := range []string{"missing", "blocked", "divergent"} {
|
||||
t.Run(state, func(t *testing.T) {
|
||||
previous := requireRuntimeAuthProjectionReady
|
||||
@@ -61,6 +64,26 @@ func TestStartRefusesProjectedAuthenticationBeforeComposeWhenNotReady(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartRefusesProjectionFailureBeforeCompose(t *testing.T) {
|
||||
stubModelProjection(t, errors.New("synthetic projection failure"))
|
||||
runner := &recordingRunner{}
|
||||
|
||||
err := Start(context.Background(), testInstallation(), runner, false)
|
||||
if err == nil || !strings.Contains(err.Error(), "model runtime projection") {
|
||||
t.Fatalf("Start() error = %v", err)
|
||||
}
|
||||
if len(runner.stages) != 0 {
|
||||
t.Fatalf("Start() reached Compose: %v", runner.stages)
|
||||
}
|
||||
}
|
||||
|
||||
func stubModelProjection(t *testing.T, result error) {
|
||||
t.Helper()
|
||||
previous := generateModelProjections
|
||||
generateModelProjections = func(config.Installation) error { return result }
|
||||
t.Cleanup(func() { generateModelProjections = previous })
|
||||
}
|
||||
|
||||
type recordingRunner struct{ stages []string }
|
||||
|
||||
func (r *recordingRunner) Run(_ context.Context, args []string, _ io.Reader) (compose.Result, error) {
|
||||
|
||||
Reference in New Issue
Block a user