Unverified Commit 567981aa authored by yacovm's avatar yacovm Committed by Artem Barger
Browse files

[FAB-13298] Fix test flake on MacOS

https://gerrit.hyperledger.org/r/#/c/28202/


Fixed a problem on MacOS but it seems that the error string
that is returned from the operating system's system call
differs on linux and Mac.

This change set addresses this by making the panic error
comparison look for a substring instead of a full comparison.

Change-Id: Idf10bff7b4dde6009ce01bb83b7bd576be4df2b4
Signed-off-by: default avataryacovm <yacovm@il.ibm.com>
parent 6e34e329
......@@ -526,7 +526,7 @@ func TestConfigureClusterListener(t *testing.T) {
},
},
expectedPanic: fmt.Sprintf("Failed creating gRPC server on 99.99.99.99:%d due "+
"to listen tcp 99.99.99.99:%d: bind: cannot assign requested address", unUsedPort, unUsedPort),
"to listen tcp 99.99.99.99:%d:", unUsedPort, unUsedPort),
generalSrv: &comm.GRPCServer{},
},
{
......@@ -557,7 +557,7 @@ func TestConfigureClusterListener(t *testing.T) {
f := func() {
configureClusterListener(testCase.conf, testCase.generalConf, testCase.generalSrv, loadPEM)
}
assert.PanicsWithValue(t, testCase.expectedPanic, f)
assert.Contains(t, panicMsg(f), testCase.expectedPanic)
} else {
configureClusterListener(testCase.conf, testCase.generalConf, testCase.generalSrv, loadPEM)
}
......@@ -594,3 +594,19 @@ func genesisConfig(t *testing.T) *localconfig.TopLevel {
},
}
}
func panicMsg(f func()) string {
var message interface{}
func() {
defer func() {
message = recover()
}()
f()
}()
return message.(string)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment