Commit cab06c58 authored by Jochen Sprickerhof's avatar Jochen Sprickerhof

Adopt to new testdata

parent 17d9487b
usr/share/gocode
usr/share/gocode/src/mvdan.cc/fdroidcl/*.*
usr/share/gocode/src/mvdan.cc/fdroidcl/adb/
usr/share/gocode/src/mvdan.cc/fdroidcl/basedir/
usr/share/gocode/src/mvdan.cc/fdroidcl/fdroid/
From: Jochen Sprickerhof <jspricke@debian.org>
Date: Thu, 7 Feb 2019 08:13:39 +0100
Subject: Drop main_test.go
- Test dependency not packaged.
---
main_test.go | 81 ------------------------------------------------------------
1 file changed, 81 deletions(-)
delete mode 100644 main_test.go
diff --git a/main_test.go b/main_test.go
deleted file mode 100644
index c6305d0..0000000
--- a/main_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package main
-
-import (
- "fmt"
- "net"
- "net/http"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "testing"
-
- "github.com/rogpeppe/go-internal/testscript"
- "mvdan.cc/fdroidcl/adb"
-)
-
-func TestMain(m *testing.M) {
- if os.Getenv("TESTSCRIPT_COMMAND") == "" {
- // start the static http server once
- path := filepath.Join("testdata", "staticrepo")
- fs := http.FileServer(http.Dir(path))
- handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- // The files are static, so add a unique etag for each file.
- w.Header().Set("Etag", strconv.Quote(r.URL.Path))
- fs.ServeHTTP(w, r)
- })
- ln, err := net.Listen("tcp", ":0")
- if err != nil {
- panic(err)
- }
- server := &http.Server{Handler: handler}
- go server.Serve(ln)
- // Save it to a global, which will be added as an env var to be
- // picked up by the children processes.
- staticRepoHost = ln.Addr().String()
- } else {
- httpClient.Transport = repoTransport{os.Getenv("REPO_HOST")}
- }
-
- os.Exit(testscript.RunMain(m, map[string]func() int{
- "fdroidcl": main1,
- }))
-}
-
-type repoTransport struct {
- repoHost string
-}
-
-func (t repoTransport) RoundTrip(req *http.Request) (*http.Response, error) {
- // replace https://f-droid.org/repo/foo with http://localhost:1234/foo
- req.URL.Scheme = "http"
- req.URL.Host = t.repoHost
- req.URL.Path = strings.TrimPrefix(req.URL.Path, "/repo")
- return http.DefaultClient.Do(req)
-}
-
-var staticRepoHost string
-
-func TestScripts(t *testing.T) {
- t.Parallel()
- testscript.Run(t, testscript.Params{
- Dir: filepath.Join("testdata", "scripts"),
- Setup: func(e *testscript.Env) error {
- home := e.WorkDir + "/home"
- if err := os.MkdirAll(home, 0777); err != nil {
- return err
- }
- e.Vars = append(e.Vars, "HOME="+home)
- e.Vars = append(e.Vars, "REPO_HOST="+staticRepoHost)
- return nil
- },
- Condition: func(cond string) (bool, error) {
- switch cond {
- case "device":
- devices, err := adb.Devices()
- return err == nil && len(devices) == 1, nil
- }
- return false, fmt.Errorf("unknown condition %q", cond)
- },
- })
-}
0001-Drop-main_test.go.patch
Markdown is supported
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