Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip tests that require network access with HERMETIC=true #587

Merged
merged 2 commits into from
May 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package config
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -41,6 +42,13 @@ var validCfg = `
}
`

// Skip test when HERMETIC=true is set, since config tests require network access
func skipHermetic(t *testing.T) {
if os.Getenv("HERMETIC") != "" {
t.Skip("Skipping testing in hermetic test environment")
}
}

func TestMetaURLs(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -94,6 +102,8 @@ func TestMetaURLs(t *testing.T) {
}

func TestLoad(t *testing.T) {
skipHermetic(t)

td := t.TempDir()
cfgPath := filepath.Join(td, "config.json")
if err := ioutil.WriteFile(cfgPath, []byte(validCfg), 0644); err != nil {
Expand Down Expand Up @@ -132,6 +142,8 @@ func TestLoad(t *testing.T) {
}

func TestLoadDefaults(t *testing.T) {
skipHermetic(t)

td := t.TempDir()

// Don't put anything here!
Expand Down