Browse Source

Merge pull request #358 from Morganamilo/rmtest

Remove test for formatKeysToImport()
Anna 7 years ago
parent
commit
6118a9f8b6
1 changed files with 0 additions and 88 deletions
  1. 0 88
      keys_test.go

+ 0 - 88
keys_test.go

@@ -62,94 +62,6 @@ func startPgpKeyServer() *http.Server {
 	return srv
 }
 
-func TestFormatKeysToImport(t *testing.T) {
-	casetests := []struct {
-		keySet    pgpKeySet
-		bases     map[string][]*rpc.Pkg
-		expected  string
-		alternate string
-		wantError bool
-	}{
-		// Single key, required by single package.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo\n%s Import?", arrow),
-			wantError: false,
-		},
-		// Single key, required by two packages.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo"), newPkg("PKG-bar")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo PKG-bar\n%s Import?", arrow),
-			wantError: false,
-		},
-		// Two keys, each required by a single package. Since iterating the map
-		// does not force any particular order, we cannot really predict the
-		// order in which the elements will appear. As we have only two cases,
-		// let's add the second possibility to the alternate variable, to check
-		// if there are any errors.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo")}, "KEY-2": []*rpc.Pkg{newPkg("PKG-bar")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo\n\tKEY-2, required by: PKG-bar\n%s Import?", arrow),
-			alternate: fmt.Sprintf("GPG keys need importing:\n\tKEY-2, required by: PKG-bar\n\tKEY-1, required by: PKG-foo\n%s Import?", arrow),
-			wantError: false,
-		},
-		// Two keys required by single package.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo")}, "KEY-2": []*rpc.Pkg{newPkg("PKG-foo")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo\n\tKEY-2, required by: PKG-foo\n%s Import?", arrow),
-			alternate: fmt.Sprintf("GPG keys need importing:\n\tKEY-2, required by: PKG-foo\n\tKEY-1, required by: PKG-foo\n%s Import?", arrow),
-			wantError: false,
-		},
-		// Two keys, one of them required by two packages.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo"), newPkg("PKG-bar")}, "KEY-2": []*rpc.Pkg{newPkg("PKG-bar")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo PKG-bar\n\tKEY-2, required by: PKG-bar\n%s Import?", arrow),
-			alternate: fmt.Sprintf("GPG keys need importing:\n\tKEY-2, required by: PKG-bar\n\tKEY-1, required by: PKG-foo PKG-bar\n%s Import?", arrow),
-			wantError: false,
-		},
-		// Two keys, split package (linux-ck/linux-ck-headers).
-		{
-			keySet: pgpKeySet{"ABAF11C65A2970B130ABE3C479BE3E4300411886": []*rpc.Pkg{newPkg("linux-ck")}, "647F28654894E3BD457199BE38DBBDC86092693E": []*rpc.Pkg{newPkg("linux-ck")}},
-
-			bases:     map[string][]*rpc.Pkg{"linux-ck": {newSplitPkg("linux-ck", "linux-ck-headers"), newPkg("linux-ck")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tABAF11C65A2970B130ABE3C479BE3E4300411886, required by: linux-ck (linux-ck-headers linux-ck)\n\t647F28654894E3BD457199BE38DBBDC86092693E, required by: linux-ck (linux-ck-headers linux-ck)\n%s Import?", arrow),
-			alternate: fmt.Sprintf("GPG keys need importing:\n\t647F28654894E3BD457199BE38DBBDC86092693E, required by: linux-ck (linux-ck-headers linux-ck)\n\tABAF11C65A2970B130ABE3C479BE3E4300411886, required by: linux-ck (linux-ck-headers linux-ck)\n%s Import?", arrow),
-			wantError: false,
-		},
-		// One key, three split packages.
-		{
-			keySet:    pgpKeySet{"KEY-1": []*rpc.Pkg{newPkg("PKG-foo")}},
-			bases:     map[string][]*rpc.Pkg{"PKG-foo": {newPkg("PKG-foo"), newSplitPkg("PKG-foo", "PKG-foo-1"), newSplitPkg("PKG-foo", "PKG-foo-2")}},
-			expected:  fmt.Sprintf("GPG keys need importing:\n\tKEY-1, required by: PKG-foo (PKG-foo PKG-foo-1 PKG-foo-2)\n%s Import?", arrow),
-			wantError: false,
-		},
-		// No keys, should fail.
-		{
-			keySet:    pgpKeySet{},
-			expected:  "",
-			wantError: true,
-		},
-	}
-
-	for _, tt := range casetests {
-		question, err := formatKeysToImport(tt.keySet, tt.bases)
-		if !tt.wantError {
-			if err != nil {
-				t.Fatalf("Got error %q, want no error", err)
-			}
-
-			if question != tt.expected && question != tt.alternate {
-				t.Fatalf("Got %q\n, expected: %q", question, tt.expected)
-			}
-			continue
-		}
-		// Here, we want to see the error.
-		if err == nil {
-			t.Fatalf("Got no error; want error")
-		}
-	}
-}
-
 func TestImportKeys(t *testing.T) {
 	keyringDir, err := ioutil.TempDir("/tmp", "yay-test-keyring")
 	if err != nil {