|
9 | 9 | "testing" |
10 | 10 | "time" |
11 | 11 |
|
| 12 | + "github.com/google/go-cmp/cmp" |
12 | 13 | tfe "github.com/hashicorp/go-tfe" |
13 | 14 | "github.com/hashicorp/terraform/addrs" |
14 | 15 | "github.com/hashicorp/terraform/backend" |
@@ -278,16 +279,23 @@ func TestRemote_applyWithTarget(t *testing.T) { |
278 | 279 | } |
279 | 280 |
|
280 | 281 | <-run.Done() |
281 | | - if run.Result == backend.OperationSuccess { |
282 | | - t.Fatal("expected apply operation to fail") |
| 282 | + if run.Result != backend.OperationSuccess { |
| 283 | + t.Fatal("expected apply operation to succeed") |
283 | 284 | } |
284 | | - if !run.PlanEmpty { |
285 | | - t.Fatalf("expected plan to be empty") |
| 285 | + if run.PlanEmpty { |
| 286 | + t.Fatalf("expected plan to be non-empty") |
286 | 287 | } |
287 | 288 |
|
288 | | - errOutput := b.CLI.(*cli.MockUi).ErrorWriter.String() |
289 | | - if !strings.Contains(errOutput, "targeting is currently not supported") { |
290 | | - t.Fatalf("expected a targeting error, got: %v", errOutput) |
| 289 | + // We should find a run inside the mock client that has the same |
| 290 | + // target address we requested above. |
| 291 | + runsAPI := b.client.Runs.(*mockRuns) |
| 292 | + if got, want := len(runsAPI.runs), 1; got != want { |
| 293 | + t.Fatalf("wrong number of runs in the mock client %d; want %d", got, want) |
| 294 | + } |
| 295 | + for _, run := range runsAPI.runs { |
| 296 | + if diff := cmp.Diff([]string{"null_resource.foo"}, run.TargetAddrs); diff != "" { |
| 297 | + t.Errorf("wrong TargetAddrs in the created run\n%s", diff) |
| 298 | + } |
291 | 299 | } |
292 | 300 | } |
293 | 301 |
|
|
0 commit comments