From 6306ef9d6fc8903978b032e2dd35b2ec23b98d8e Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Fri, 9 Nov 2018 16:23:58 +0100 Subject: [PATCH] In remote relations change tests, relocates invocation of change event to be after all test arrangement has been executed. Also adds detail to failure output. --- worker/remoterelations/remoterelations_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/worker/remoterelations/remoterelations_test.go b/worker/remoterelations/remoterelations_test.go index 496e0552900..2aeed08c101 100644 --- a/worker/remoterelations/remoterelations_test.go +++ b/worker/remoterelations/remoterelations_test.go @@ -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 { @@ -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"}}}, @@ -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", @@ -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) }