testing/mtg: skip network tests on network error

This is not an indication of an error, and for some reason, httpbin.org
is not reachable from the ppc64le builders.
This commit is contained in:
Kevin Daudt 2021-05-28 11:06:51 +00:00
parent da4a6b1854
commit 167fd3900b
2 changed files with 33 additions and 0 deletions

View File

@ -15,6 +15,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/9seconds/mtg/archive/refs/ta
mtg.initd
mtg.confd
mtg.conf
skip-tests-on-network-error.patch
"
export GOPATH=$srcdir/go
export GOCACHE=$srcdir/go-build
@ -42,4 +43,5 @@ sha512sums="
6ce0b34b2224ea86d56f1c6911302c42a6b4aa9d13046fd0016d9adc267121fd1365829e26559875b836d0b94f9e784954949094489b7e16975d82332d241273 mtg.initd
41c3edc721fae9569596776e38fe6cebfe213cbb62b9a187fbb893eab9421d64ec5a683a54af5f1444a3e28af89402ab4d55abf9f653a64a040c0a4b684f5ece mtg.confd
340651372d8fa861bf40ead66af7fc52ee917aa62eb21bbf562bd5775ffd13ed688fe516a278aa96a8fe55ea48225ca1d9048a7bca7eaf6a5fedd563b27f21b4 mtg.conf
4dcf0949d3fc83cc7b3b971950c6d384866dba46845209a776fd1cf7b3b8169fbdb04cc4f635743b7a5be25f52b4d4be320470e11a79174d1348c2fb97b95b59 skip-tests-on-network-error.patch
"

View File

@ -0,0 +1,31 @@
Description: These tests try to connect to httpbin.org to do some testing. When
httpbin.org is not available, this does not indicate a test failure. Furthermore,
just calling suite.NoError does not stop the execution of the function, so it
would error out when respo.Body is nil.
diff --git a/network/network_test.go b/network/network_test.go
index 86b5f0c..e46a538 100644
--- a/network/network_test.go
+++ b/network/network_test.go
@@ -32,7 +32,9 @@ func (suite *NetworkTestSuite) TestLocalHTTPRequest() {
client := ntw.MakeHTTPClient(nil)
resp, err := client.Get(suite.httpServer.URL + "/headers") // nolint: noctx
- suite.NoError(err)
+ if ! suite.NoError(err) {
+ suite.T().Skip("Network error")
+ }
defer resp.Body.Close()
@@ -57,7 +59,9 @@ func (suite *NetworkTestSuite) TestRealHTTPRequest() {
client := ntw.MakeHTTPClient(nil)
resp, err := client.Get("https://httpbin.org/headers") // nolint: noctx
- suite.NoError(err)
+ if ! suite.NoError(err) {
+ suite.T().Skip("Network error")
+ }
defer resp.Body.Close()