Skip to content

Commit

Permalink
In remote relations change tests, relocates invocation of change even…
Browse files Browse the repository at this point in the history
…t to be after all test arrangement has been executed.

Also adds detail to failure output.
  • Loading branch information
manadart committed Nov 9, 2018
1 parent 7a12b3b commit 6306ef9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions worker/remoterelations/remoterelations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func waitForStubCalls(c *gc.C, stub *jujutesting.Stub, expected []jujutesting.St
return
}
}
c.Fatalf("failed to see expected calls. saw: %v", calls)
c.Fatalf("failed to see expected calls.\nexpected: %v\nobserved: %v", expected, calls)
}

func (s *remoteRelationsSuite) assertRemoteApplicationWorkers(c *gc.C) worker.Worker {
Expand Down Expand Up @@ -546,8 +546,6 @@ func (s *remoteRelationsSuite) assertRemoteRelationsChangedError(c *gc.C, dying
s.waitForWorkerStubCalls(c, expected)
s.stub.ResetCalls()

relWatcher, _ := s.relationsFacade.remoteApplicationRelationsWatcher("db2")
relWatcher.changes <- []string{"db2:db django:db"}
relTag := names.NewRelationTag("db2:db django:db")
expected = []jujutesting.StubCall{
{"Relations", []interface{}{[]string{"db2:db django:db"}}},
Expand Down Expand Up @@ -579,7 +577,8 @@ func (s *remoteRelationsSuite) assertRemoteRelationsChangedError(c *gc.C, dying
s.relationsFacade.updateRelationLife("db2:db django:db", params.Dying)
forceCleanup := true
expected = append(expected, jujutesting.StubCall{
"PublishRelationChange", []interface{}{
FuncName: "PublishRelationChange",
Args: []interface{}{
params.RemoteRelationChangeEvent{
ApplicationToken: "token-django",
RelationToken: "token-db2:db django:db",
Expand All @@ -590,6 +589,10 @@ func (s *remoteRelationsSuite) assertRemoteRelationsChangedError(c *gc.C, dying
}},
)
}

relWatcher, _ := s.relationsFacade.remoteApplicationRelationsWatcher("db2")
relWatcher.changes <- []string{"db2:db django:db"}

// After the worker resumes, normal processing happens.
s.waitForWorkerStubCalls(c, expected)
}
Expand Down

0 comments on commit 6306ef9

Please sign in to comment.