Fix flaky test by marking mock expectations as optional (#9596)

These expectations are optional because in a slow CI environment the deadline to cancell the context might occur before the go routine reaches issuing the RPC. Either way we are successfully ensuring context cancellation is working.
This commit is contained in:
Matt Keeler 2021-01-20 10:58:27 -05:00 committed by hashicorp-ci
parent 7bb043a42d
commit 87f7bb475c
1 changed files with 2 additions and 2 deletions

View File

@ -248,8 +248,8 @@ func TestInitialConfiguration_cancelled(t *testing.T) {
JWT: "blarg",
}
mcfg.directRPC.On("RPC", "dc1", "autoconf", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8300}, "AutoConfig.InitialConfiguration", &expectedRequest, mock.Anything).Return(fmt.Errorf("injected error")).Times(0)
mcfg.serverProvider.On("FindLANServer").Return(nil).Times(0)
mcfg.directRPC.On("RPC", "dc1", "autoconf", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8300}, "AutoConfig.InitialConfiguration", &expectedRequest, mock.Anything).Return(fmt.Errorf("injected error")).Times(0).Maybe()
mcfg.serverProvider.On("FindLANServer").Return(nil).Times(0).Maybe()
ac, err := New(mcfg.Config)
require.NoError(t, err)