Fix integration tests

This fixes the integration tests:

* Expect and allow the update header.

* Don't print the local permalink if there's an error.
This commit is contained in:
joeduffy 2018-09-05 11:39:58 -07:00
parent b1f7cf7050
commit c1967129e7
2 changed files with 17 additions and 12 deletions

View file

@ -283,15 +283,6 @@ func (b *localBackend) apply(ctx context.Context, kind apitype.UpdateKind, stack
return nil, err
}
// Make sure to print a link to the stack's checkpoint before exiting.
if persist {
defer func() {
fmt.Printf(
op.Opts.Display.Color.Colorize(
colors.BrightMagenta+"Permalink: file://%s"+colors.Reset+"\n"), stack.(*localStack).Path())
}()
}
// Spawn a display loop to show events on the CLI.
displayEvents := make(chan engine.Event)
displayDone := make(chan bool)
@ -369,6 +360,7 @@ func (b *localBackend) apply(ctx context.Context, kind apitype.UpdateKind, stack
// trivial to achieve today given the event driven nature of plan-walking, however.
ResourceChanges: changes,
}
var saveErr error
var backupErr error
if !dryRun {
@ -380,11 +372,24 @@ func (b *localBackend) apply(ctx context.Context, kind apitype.UpdateKind, stack
// We swallow saveErr and backupErr as they are less important than the updateErr.
return changes, updateErr
}
if saveErr != nil {
// We swallow backupErr as it is less important than the saveErr.
return changes, errors.Wrap(saveErr, "saving update info")
}
return changes, errors.Wrap(backupErr, "saving backup")
if backupErr != nil {
return changes, errors.Wrap(backupErr, "saving backup")
}
// Make sure to print a link to the stack's checkpoint before exiting.
if persist {
fmt.Printf(
op.Opts.Display.Color.Colorize(
colors.BrightMagenta+"Permalink: file://%s"+colors.Reset+"\n"), stack.(*localStack).Path())
}
return changes, nil
}
func (b *localBackend) GetHistory(ctx context.Context, stackRef backend.StackReference) ([]backend.UpdateInfo, error) {

View file

@ -70,7 +70,7 @@ func TestProjectMain(t *testing.T) {
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "stack", "init", "main-abs")
stdout, stderr := e.RunCommandExpectError("pulumi", "up", "--non-interactive", "--skip-preview", "--yes")
assert.Equal(t, "", stdout)
assert.Equal(t, "Updating stack 'main-abs'\n", stdout)
assert.Contains(t, stderr, "project 'main' must be a relative path")
e.RunCommand("pulumi", "stack", "rm", "--yes")
})
@ -86,7 +86,7 @@ func TestProjectMain(t *testing.T) {
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "stack", "init", "main-parent")
stdout, stderr := e.RunCommandExpectError("pulumi", "up", "--non-interactive", "--skip-preview", "--yes")
assert.Equal(t, "", stdout)
assert.Equal(t, "Updating stack 'main-parent'\n", stdout)
assert.Contains(t, stderr, "project 'main' must be a subfolder")
e.RunCommand("pulumi", "stack", "rm", "--yes")
})