mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-23 14:03:33 -04:00
app-shells/antibody: Remove tests that require internet access.
Closes: https://bugs.gentoo.org/783999 Signed-off-by: Ronny (tastytea) Gutbrod <gentoo@tastytea.de>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright 2020 Gentoo Authors
|
||||
# Copyright 2020-2021 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
@@ -59,6 +59,8 @@ RDEPEND="
|
||||
dev-vcs/git
|
||||
"
|
||||
|
||||
PATCHES=( "${FILESDIR}/${PN}-6.1.1_remove-failing-tests.patch" )
|
||||
|
||||
src_compile() {
|
||||
local -a mygoargs=(
|
||||
-ldflags "-X main.version=${PV}"
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
From 0030445c7fef2c1fcf6701d77ee1e3400c044dea Mon Sep 17 00:00:00 2001
|
||||
From: tastytea <tastytea@tastytea.de>
|
||||
Date: Mon, 19 Apr 2021 09:24:31 +0200
|
||||
Subject: [PATCH] Remove failing tests.
|
||||
|
||||
Remove all tests which require network access. Unused imports make the
|
||||
tests fail.
|
||||
---
|
||||
antibodylib/antibody_test.go | 105 +------------------------------
|
||||
bundle/bundle_test.go | 59 ------------------
|
||||
project/git_test.go | 117 -----------------------------------
|
||||
project/project_test.go | 46 --------------
|
||||
4 files changed, 2 insertions(+), 325 deletions(-)
|
||||
|
||||
diff --git a/antibodylib/antibody_test.go b/antibodylib/antibody_test.go
|
||||
index 752ca07..ea2d7ee 100644
|
||||
--- a/antibodylib/antibody_test.go
|
||||
+++ b/antibodylib/antibody_test.go
|
||||
@@ -5,40 +5,11 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
- "strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
-func TestAntibody(t *testing.T) {
|
||||
- home := home()
|
||||
- bundles := []string{
|
||||
- "# comments also are allowed",
|
||||
- "caarlos0/ports kind:path # comment at the end of the line",
|
||||
- "caarlos0/jvm kind:path branch:gh-pages",
|
||||
- "caarlos0/zsh-open-pr kind:zsh",
|
||||
- "",
|
||||
- " ",
|
||||
- " # trick play",
|
||||
- "/tmp kind:path",
|
||||
- }
|
||||
- sh, err := New(
|
||||
- home,
|
||||
- bytes.NewBufferString(strings.Join(bundles, "\n")),
|
||||
- runtime.NumCPU(),
|
||||
- ).Bundle()
|
||||
- require.NoError(t, err)
|
||||
- files, err := ioutil.ReadDir(home)
|
||||
- require.NoError(t, err)
|
||||
- require.Len(t, files, 3)
|
||||
- require.Contains(t, sh, `export PATH="/tmp:$PATH"`)
|
||||
- require.Contains(t, sh, `export PATH="`+home+`/https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-ports:$PATH"`)
|
||||
- require.Contains(t, sh, `export PATH="`+home+`/https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-jvm:$PATH"`)
|
||||
- // nolint: lll
|
||||
- require.Contains(t, sh, `source `+home+`/https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-zsh-open-pr/git-open-pr.plugin.zsh`)
|
||||
-}
|
||||
-
|
||||
func TestAntibodyError(t *testing.T) {
|
||||
home := home()
|
||||
bundles := bytes.NewBufferString("invalid-repo")
|
||||
@@ -47,80 +18,8 @@ func TestAntibodyError(t *testing.T) {
|
||||
require.Empty(t, sh)
|
||||
}
|
||||
|
||||
-func TestMultipleRepositories(t *testing.T) {
|
||||
- home := home()
|
||||
- bundles := []string{
|
||||
- "# this block is in alphabetic order",
|
||||
- "caarlos0/git-add-remote kind:path",
|
||||
- "caarlos0/jvm",
|
||||
- "caarlos0/ports kind:path",
|
||||
- "caarlos0/zsh-git-fetch-merge kind:path",
|
||||
- "caarlos0/zsh-git-sync kind:path",
|
||||
- "caarlos0/zsh-mkc",
|
||||
- "caarlos0/zsh-open-pr kind:path",
|
||||
- "mafredri/zsh-async",
|
||||
- "rupa/z",
|
||||
- "Tarrasch/zsh-bd",
|
||||
- "wbinglee/zsh-wakatime",
|
||||
- "zsh-users/zsh-completions",
|
||||
- "zsh-users/zsh-autosuggestions",
|
||||
- "",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/asdf",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/autoenv",
|
||||
- "# these should be at last!",
|
||||
- "sindresorhus/pure",
|
||||
- "zsh-users/zsh-syntax-highlighting",
|
||||
- "zsh-users/zsh-history-substring-search",
|
||||
- }
|
||||
- sh, err := New(
|
||||
- home,
|
||||
- bytes.NewBufferString(strings.Join(bundles, "\n")),
|
||||
- runtime.NumCPU(),
|
||||
- ).Bundle()
|
||||
- require.NoError(t, err)
|
||||
- require.Len(t, strings.Split(sh, "\n"), 31)
|
||||
-}
|
||||
-
|
||||
-// BenchmarkDownload-8 1 2907868713 ns/op 480296 B/op 2996 allocs/op v1
|
||||
-// BenchmarkDownload-8 1 2708120385 ns/op 475904 B/op 3052 allocs/op v2
|
||||
-func BenchmarkDownload(b *testing.B) {
|
||||
- var bundles = strings.Join([]string{
|
||||
- "robbyrussell/oh-my-zsh path:plugins/aws",
|
||||
- "caarlos0/git-add-remote kind:path",
|
||||
- "caarlos0/jvm",
|
||||
- "caarlos0/ports kind:path",
|
||||
- "",
|
||||
- "# comment whatever",
|
||||
- "caarlos0/zsh-git-fetch-merge kind:path",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/battery",
|
||||
- "caarlos0/zsh-git-sync kind:path",
|
||||
- "caarlos0/zsh-mkc",
|
||||
- "caarlos0/zsh-open-pr kind:path",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/asdf",
|
||||
- "mafredri/zsh-async",
|
||||
- "rupa/z",
|
||||
- "Tarrasch/zsh-bd",
|
||||
- "",
|
||||
- "Linuxbrew/brew path:completions/zsh kind:fpath",
|
||||
- "wbinglee/zsh-wakatime",
|
||||
- "zsh-users/zsh-completions",
|
||||
- "zsh-users/zsh-autosuggestions",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/autoenv",
|
||||
- "# these should be at last!",
|
||||
- "sindresorhus/pure",
|
||||
- "zsh-users/zsh-syntax-highlighting",
|
||||
- "zsh-users/zsh-history-substring-search",
|
||||
- }, "\n")
|
||||
- for i := 0; i < b.N; i++ {
|
||||
- home := home()
|
||||
- _, err := New(
|
||||
- home,
|
||||
- bytes.NewBufferString(bundles),
|
||||
- runtime.NumCPU(),
|
||||
- ).Bundle()
|
||||
- require.NoError(b, err)
|
||||
- }
|
||||
-}
|
||||
+// BenchmarkDownload-8 1 2907868713 ns/op 480296 B/op 2996 allocs/op v1
|
||||
+// BenchmarkDownload-8 1 2708120385 ns/op 475904 B/op 3052 allocs/op v2
|
||||
|
||||
func TestHome(t *testing.T) {
|
||||
h, err := Home()
|
||||
diff --git a/bundle/bundle_test.go b/bundle/bundle_test.go
|
||||
index 78c4b70..4c72d34 100644
|
||||
--- a/bundle/bundle_test.go
|
||||
+++ b/bundle/bundle_test.go
|
||||
@@ -9,57 +9,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
-func TestSuccessfullGitBundles(t *testing.T) {
|
||||
- table := []struct {
|
||||
- line, result string
|
||||
- }{
|
||||
- {
|
||||
- "caarlos0/jvm",
|
||||
- "jvm.plugin.zsh\nfpath+=( ",
|
||||
- },
|
||||
- {
|
||||
- "caarlos0/jvm kind:path",
|
||||
- "export PATH=\"",
|
||||
- },
|
||||
- {
|
||||
- "caarlos0/jvm kind:path branch:gh-pages",
|
||||
- "export PATH=\"",
|
||||
- },
|
||||
- {
|
||||
- "caarlos0/jvm kind:dummy",
|
||||
- "",
|
||||
- },
|
||||
- {
|
||||
- "caarlos0/jvm kind:fpath",
|
||||
- "fpath+=( ",
|
||||
- },
|
||||
- {
|
||||
- "docker/cli path:contrib/completion/zsh/_docker",
|
||||
- "contrib/completion/zsh/_docker",
|
||||
- },
|
||||
- }
|
||||
- for _, row := range table {
|
||||
- row := row
|
||||
- t.Run(row.line, func(t *testing.T) {
|
||||
- t.Parallel()
|
||||
- home := home(t)
|
||||
- bundle, err := New(home, row.line)
|
||||
- require.NoError(t, err)
|
||||
- result, err := bundle.Get()
|
||||
- require.Contains(t, result, row.result)
|
||||
- require.NoError(t, err)
|
||||
- })
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-func TestZshInvalidGitBundle(t *testing.T) {
|
||||
- home := home(t)
|
||||
- bundle, err := New(home, "does not exist")
|
||||
- require.NoError(t, err)
|
||||
- _, err = bundle.Get()
|
||||
- require.Error(t, err)
|
||||
-}
|
||||
-
|
||||
func TestZshLocalBundle(t *testing.T) {
|
||||
home := home(t)
|
||||
// nolint: gosec
|
||||
@@ -79,14 +28,6 @@ func TestZshInvalidLocalBundle(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
-func TestZshBundleWithNoShFiles(t *testing.T) {
|
||||
- home := home(t)
|
||||
- bundle, err := New(home, "getantibody/antibody")
|
||||
- require.NoError(t, err)
|
||||
- _, err = bundle.Get()
|
||||
- require.NoError(t, err)
|
||||
-}
|
||||
-
|
||||
func TestPathInvalidLocalBundle(t *testing.T) {
|
||||
home := home(t)
|
||||
bundle, err := New(home, "/asduhasd/asdasda kind:path")
|
||||
diff --git a/project/git_test.go b/project/git_test.go
|
||||
index f238317..c014be0 100644
|
||||
--- a/project/git_test.go
|
||||
+++ b/project/git_test.go
|
||||
@@ -3,125 +3,8 @@ package project
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
- "path/filepath"
|
||||
- "strings"
|
||||
- "testing"
|
||||
-
|
||||
- "github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
-func TestDownloadAllKinds(t *testing.T) {
|
||||
- urls := []string{
|
||||
- "caarlos0/ports",
|
||||
- "http://github.com/caarlos0/ports",
|
||||
- "http://github.com/caarlos0/ports.git",
|
||||
- "https://github.com/caarlos0/ports",
|
||||
- "https://github.com/caarlos0/ports.git",
|
||||
- "git://github.com/caarlos0/ports.git",
|
||||
- "https://gitlab.com/caarlos0/test.git",
|
||||
- // FIXME: those fail on travis:
|
||||
- // "git@gitlab.com:caarlos0/test.git",
|
||||
- // "ssh://git@github.com/caarlos0/ports.git",
|
||||
- // "git@github.com:caarlos0/ports.git",
|
||||
- }
|
||||
- for _, url := range urls {
|
||||
- home := home()
|
||||
- require.NoError(
|
||||
- t,
|
||||
- NewGit(home, url).Download(),
|
||||
- "Repo "+url+" failed to download",
|
||||
- )
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-func TestDownloadSubmodules(t *testing.T) {
|
||||
- var home = home()
|
||||
- var proj = NewGit(home, "fribmendes/geometry branch:master")
|
||||
- var module = filepath.Join(proj.Path(), "lib/zsh-async")
|
||||
- require.NoError(t, proj.Download())
|
||||
- require.NoError(t, proj.Update())
|
||||
- files, err := ioutil.ReadDir(module)
|
||||
- require.NoError(t, err)
|
||||
- require.True(t, len(files) > 1)
|
||||
-}
|
||||
-
|
||||
-func TestDownloadAnotherBranch(t *testing.T) {
|
||||
- home := home()
|
||||
- require.NoError(t, NewGit(home, "caarlos0/jvm branch:gh-pages").Download())
|
||||
-}
|
||||
-
|
||||
-func TestUpdateAnotherBranch(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/jvm branch:gh-pages")
|
||||
- require.NoError(t, repo.Download())
|
||||
- alreadyClonedRepo := NewClonedGit(home, "https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-jvm")
|
||||
- require.NoError(t, alreadyClonedRepo.Update())
|
||||
-}
|
||||
-
|
||||
-func TestUpdateExistentLocalRepo(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/ports")
|
||||
- require.NoError(t, repo.Download())
|
||||
- alreadyClonedRepo := NewClonedGit(home, "https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-ports")
|
||||
- require.NoError(t, alreadyClonedRepo.Update())
|
||||
-}
|
||||
-
|
||||
-func TestUpdateNonExistentLocalRepo(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/ports")
|
||||
- require.Error(t, repo.Update())
|
||||
-}
|
||||
-
|
||||
-func TestDownloadNonExistentRepo(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/not-a-real-repo")
|
||||
- require.Error(t, repo.Download())
|
||||
-}
|
||||
-
|
||||
-func TestDownloadMalformedRepo(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "doesn-not-exist-really branch:also-nope")
|
||||
- require.Error(t, repo.Download())
|
||||
-}
|
||||
-
|
||||
-func TestDownloadMultipleTimes(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/ports")
|
||||
- require.NoError(t, repo.Download())
|
||||
- require.NoError(t, repo.Download())
|
||||
- require.NoError(t, repo.Update())
|
||||
-}
|
||||
-
|
||||
-func TestDownloadFolderNaming(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "caarlos0/ports")
|
||||
- require.Equal(
|
||||
- t,
|
||||
- home+"/https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-ports",
|
||||
- repo.Path(),
|
||||
- )
|
||||
-}
|
||||
-
|
||||
-func TestSubFolder(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "robbyrussell/oh-my-zsh path:plugins/aws")
|
||||
- require.True(t, strings.HasSuffix(repo.Path(), "plugins/aws"))
|
||||
-}
|
||||
-
|
||||
-func TestPath(t *testing.T) {
|
||||
- home := home()
|
||||
- repo := NewGit(home, "docker/cli path:contrib/completion/zsh/_docker")
|
||||
- require.True(t, strings.HasSuffix(repo.Path(), "contrib/completion/zsh/_docker"))
|
||||
-}
|
||||
-
|
||||
-func TestMultipleSubFolders(t *testing.T) {
|
||||
- home := home()
|
||||
- require.NoError(t, NewGit(home, strings.Join([]string{
|
||||
- "robbyrussell/oh-my-zsh path:plugins/aws",
|
||||
- "robbyrussell/oh-my-zsh path:plugins/battery",
|
||||
- }, "\n")).Download())
|
||||
-}
|
||||
-
|
||||
func home() string {
|
||||
home, err := ioutil.TempDir(os.TempDir(), "antibody")
|
||||
if err != nil {
|
||||
diff --git a/project/project_test.go b/project/project_test.go
|
||||
index 88c82e3..2fd8a25 100644
|
||||
--- a/project/project_test.go
|
||||
+++ b/project/project_test.go
|
||||
@@ -1,24 +1,12 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
- "os"
|
||||
- "path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
-func TestList(t *testing.T) {
|
||||
- home := home()
|
||||
- proj, err := New(home, "caarlos0/jvm branch:gh-pages")
|
||||
- require.NoError(t, err)
|
||||
- require.NoError(t, proj.Download())
|
||||
- list, err := List(home)
|
||||
- require.NoError(t, err)
|
||||
- require.Len(t, list, 1)
|
||||
-}
|
||||
-
|
||||
func TestListEmptyFolder(t *testing.T) {
|
||||
home := home()
|
||||
list, err := List(home)
|
||||
@@ -32,40 +20,6 @@ func TestListNonExistentFolder(t *testing.T) {
|
||||
require.Len(t, list, 0)
|
||||
}
|
||||
|
||||
-func TestUpdate(t *testing.T) {
|
||||
- home := home()
|
||||
- repo, err := New(home, "caarlos0/ports")
|
||||
- require.NoError(t, err)
|
||||
- require.NoError(t, repo.Download())
|
||||
- require.NoError(t, repo.Update())
|
||||
-}
|
||||
-
|
||||
-func TestUpdateHome(t *testing.T) {
|
||||
- home := home()
|
||||
- for _, tt := range []string{
|
||||
- "caarlos0/jvm",
|
||||
- "caarlos0/ports",
|
||||
- "/tmp",
|
||||
- } {
|
||||
- tt := tt
|
||||
- t.Run(tt, func(t *testing.T) {
|
||||
- proj, err := New(home, tt)
|
||||
- require.NoError(t, err)
|
||||
- require.NoError(t, proj.Download())
|
||||
- require.NoError(t, Update(home, runtime.NumCPU()))
|
||||
- })
|
||||
- }
|
||||
-}
|
||||
-
|
||||
func TestUpdateNonExistentHome(t *testing.T) {
|
||||
require.Error(t, Update("/tmp/asdasdasdasksksksksnopeeeee", runtime.NumCPU()))
|
||||
}
|
||||
-
|
||||
-func TestUpdateHomeWithNoGitProjects(t *testing.T) {
|
||||
- home := home()
|
||||
- repo, err := New(home, "caarlos0/jvm")
|
||||
- require.NoError(t, err)
|
||||
- require.NoError(t, repo.Download())
|
||||
- require.NoError(t, os.RemoveAll(filepath.Join(repo.Path(), ".git")))
|
||||
- require.Error(t, Update(home, runtime.NumCPU()))
|
||||
-}
|
||||
--
|
||||
2.26.3
|
||||
|
||||
Reference in New Issue
Block a user