From 3e612daa98acb855e097da103b477f404e438c10 Mon Sep 17 00:00:00 2001 From: bashbunni Date: Tue, 3 Dec 2024 15:11:42 -0800 Subject: [PATCH] test: skip networked tests if no connection --- glow_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glow_test.go b/glow_test.go index 1a8ad186..263177a2 100644 --- a/glow_test.go +++ b/glow_test.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "strings" "testing" ) @@ -16,6 +17,13 @@ func TestGlowSources(t *testing.T) { for _, v := range tt { t.Run(v, func(t *testing.T) { + // Start by checking for network issues. + _, nerr := readmeURL(v) + if nerr != nil && strings.Contains(nerr.Error(), "no such host") { + t.Logf("Error during execution (args: %s):\n%v", v, nerr) + t.Skip("Test uses network. Are you connected to the Internet?") + } + buf := &bytes.Buffer{} err := executeArg(rootCmd, v, buf) if err != nil {