Package: fdroidcl / 0.5.0-3

0001-Drop-main_test.go.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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)
-		},
-	})
-}