diff options
Diffstat (limited to '')
-rw-r--r-- | tools/govanity/e2e_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/govanity/e2e_test.go b/tools/govanity/e2e_test.go new file mode 100644 index 0000000..4ec299a --- /dev/null +++ b/tools/govanity/e2e_test.go @@ -0,0 +1,40 @@ +package main + +import ( + "io/ioutil" + "net" + "net/http" + "testing" + + "gopkg.in/yaml.v3" +) + +func TestConfigurationURL(t *testing.T) { + // we try a DNS resolution first. If it fails, it means we're + // likely in the sandbox, and we need to skip this test. + _, err := net.LookupHost("fcuny.net") + if err != nil { + t.Skipf("no network connectivity: %v", err) + } + + buf, err := ioutil.ReadFile("vanity.yaml") + if err != nil { + t.Fatalf("failed to read the configuration file: %v", err) + } + + cfg := &config{} + err = yaml.Unmarshal(buf, cfg) + if err != nil { + t.Fatalf("failed to parse the YAML configuration: %v", err) + } + + for _, r := range cfg.Repositories { + res, err := http.Get(r.Repo) + if err != nil { + t.Errorf("failed to request %s: %v", r.Repo, err) + } + if res.StatusCode != http.StatusOK { + t.Errorf("HTTP status for %s is: %d - %s", r.Repo, res.StatusCode, res.Status) + } + } +} |