test(search): provide feature detection dependency
Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
parent
257f143711
commit
188098d592
3 changed files with 12 additions and 9 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/repo/view"
|
||||
|
|
@ -125,7 +126,7 @@ func Test_getExtensionRepos(t *testing.T) {
|
|||
}),
|
||||
)
|
||||
|
||||
searcher := search.NewSearcher(client, "github.com")
|
||||
searcher := search.NewSearcher(client, "github.com", &fd.DisabledDetectorMock{})
|
||||
emMock := &extensions.ExtensionManagerMock{}
|
||||
emMock.ListFunc = func() []extensions.Extension {
|
||||
return []extensions.Extension{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/config"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
ghmock "github.com/cli/cli/v2/internal/gh/mock"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -336,7 +337,7 @@ func TestCodeRun(t *testing.T) {
|
|||
Extension: "go",
|
||||
},
|
||||
},
|
||||
Searcher: search.NewSearcher(nil, "github.com"),
|
||||
Searcher: search.NewSearcher(nil, "github.com", &fd.DisabledDetectorMock{}),
|
||||
WebMode: true,
|
||||
},
|
||||
wantBrowse: "https://github.com/search?q=map+path%3Atesting.go&type=code",
|
||||
|
|
@ -354,7 +355,7 @@ func TestCodeRun(t *testing.T) {
|
|||
Extension: ".cpp",
|
||||
},
|
||||
},
|
||||
Searcher: search.NewSearcher(nil, "github.com"),
|
||||
Searcher: search.NewSearcher(nil, "github.com", &fd.DisabledDetectorMock{}),
|
||||
WebMode: true,
|
||||
},
|
||||
wantBrowse: "https://github.com/search?q=map+path%3Atesting.cpp&type=code",
|
||||
|
|
@ -381,7 +382,7 @@ func TestCodeRun(t *testing.T) {
|
|||
Extension: "go",
|
||||
},
|
||||
},
|
||||
Searcher: search.NewSearcher(nil, "example.com"),
|
||||
Searcher: search.NewSearcher(nil, "example.com", &fd.DisabledDetectorMock{}),
|
||||
WebMode: true,
|
||||
},
|
||||
wantBrowse: "https://example.com/search?q=map+extension%3Ago+filename%3Atesting&type=code",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -265,7 +266,7 @@ func TestSearcherCode(t *testing.T) {
|
|||
if tt.host == "" {
|
||||
tt.host = "github.com"
|
||||
}
|
||||
searcher := NewSearcher(client, tt.host)
|
||||
searcher := NewSearcher(client, tt.host, &fd.DisabledDetectorMock{})
|
||||
result, err := searcher.Code(tt.query)
|
||||
if tt.wantErr {
|
||||
assert.EqualError(t, err, tt.errMsg)
|
||||
|
|
@ -551,7 +552,7 @@ func TestSearcherCommits(t *testing.T) {
|
|||
if tt.host == "" {
|
||||
tt.host = "github.com"
|
||||
}
|
||||
searcher := NewSearcher(client, tt.host)
|
||||
searcher := NewSearcher(client, tt.host, &fd.DisabledDetectorMock{})
|
||||
result, err := searcher.Commits(tt.query)
|
||||
if tt.wantErr {
|
||||
assert.EqualError(t, err, tt.errMsg)
|
||||
|
|
@ -837,7 +838,7 @@ func TestSearcherRepositories(t *testing.T) {
|
|||
if tt.host == "" {
|
||||
tt.host = "github.com"
|
||||
}
|
||||
searcher := NewSearcher(client, tt.host)
|
||||
searcher := NewSearcher(client, tt.host, &fd.DisabledDetectorMock{})
|
||||
result, err := searcher.Repositories(tt.query)
|
||||
if tt.wantErr {
|
||||
assert.EqualError(t, err, tt.errMsg)
|
||||
|
|
@ -1123,7 +1124,7 @@ func TestSearcherIssues(t *testing.T) {
|
|||
if tt.host == "" {
|
||||
tt.host = "github.com"
|
||||
}
|
||||
searcher := NewSearcher(client, tt.host)
|
||||
searcher := NewSearcher(client, tt.host, fd.AdvancedIssueSearchUnsupported())
|
||||
result, err := searcher.Issues(tt.query)
|
||||
if tt.wantErr {
|
||||
assert.EqualError(t, err, tt.errMsg)
|
||||
|
|
@ -1179,7 +1180,7 @@ func TestSearcherURL(t *testing.T) {
|
|||
if tt.host == "" {
|
||||
tt.host = "github.com"
|
||||
}
|
||||
searcher := NewSearcher(nil, tt.host)
|
||||
searcher := NewSearcher(nil, tt.host, nil)
|
||||
assert.Equal(t, tt.url, searcher.URL(tt.query))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue