[goldctl] Remove test for CloudClient#matchImageAgainstBaseline() that uses a fake imgmatching.Matcher.
The deleted test became obsolete after TestCloudClient_MatchImageAgainstBaseline_FuzzyMatching_UntriagedImage_Success was introduced, which tests CloudClient#matchImageAgainstBaseline() using a real imgmatchng.Matcher as opposed to a fake one.
This CL also removes mock.MatcherFactory, which was only used by the deleted test.
A followup CL will replace the imgmatching.MatcherFactory interface (which was only introduced for testing purposes) and its imgmatching.MatcherFactoryImpl implementation with a factory function.
Bug: skia:9527
Change-Id: Id3cb253887e84a3cb1c0f2301b0a1abca0694f1e
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/279017
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/gold-client/go/goldclient/goldclient_test.go b/gold-client/go/goldclient/goldclient_test.go
index aa9110b..f3c96b4 100644
--- a/gold-client/go/goldclient/goldclient_test.go
+++ b/gold-client/go/goldclient/goldclient_test.go
@@ -1661,55 +1661,6 @@
assert.Contains(t, err.Error(), "unrecognized image matching algorithm")
}
-// fakeMatcher implements the imgmatching.Matcher interface.
-type fakeMatcher bool
-
-// Match implements the imgmatching.Matcher interface.
-func (v fakeMatcher) Match(_, _ image.Image) bool { return bool(v) }
-
-// TODO(lovisolo): Replace this test with one that uses a real non-exact image matching algorithm
-// once one is implemented.
-func TestCloudClient_MatchImageAgainstBaseline_FakeNonExactAlgorithm_DownloadsMostRecentPositiveDigest_ImagesCorrectlyPassedToAlgorithm_Success(t *testing.T) {
- unittest.MediumTest(t) // This test reads/writes a small amount of data from/to disk.
-
- const testName = types.TestName("my_test")
- const traceId = tiling.TraceID(",name=my_test,")
- imageBytes := imageToPngBytes(t, image1)
- const digest = types.Digest("11111111111111111111111111111111")
- optionalKeys := map[string]string{
- imgmatching.AlgorithmOptionalKey: "FakeAlgorithm",
- }
-
- const latestPositiveDigestRpcUrl = "https://testing-gold.skia.org/json/latestpositivedigest/,name=my_test,"
- const latestPositiveDigestResponse = `{"digest":"22222222222222222222222222222222"}`
- const latestPositiveDigestGcsPath = "gs://skia-gold-testing/dm-images-v1/22222222222222222222222222222222.png"
- latestPositiveImageBytes := imageToPngBytes(t, image2)
-
- test := func(name string, matcherReturnValue bool) {
- t.Run(name, func(t *testing.T) {
- mockMatcherFactory := &mocks.MatcherFactory{}
-
- goldClient, cleanup, httpClient, gcsClient := makeGoldClientForMatchImageAgainstBaselineTests(t)
- goldClient.imgMatcherFactory = mockMatcherFactory
- defer cleanup()
- defer mockMatcherFactory.AssertExpectations(t)
- defer httpClient.AssertExpectations(t)
- defer gcsClient.AssertExpectations(t)
-
- httpClient.On("Get", latestPositiveDigestRpcUrl).Return(httpResponse([]byte(latestPositiveDigestResponse), "200 OK", http.StatusOK), nil)
- gcsClient.On("Download", testutils.AnyContext, latestPositiveDigestGcsPath, filepath.Join(goldClient.workDir, digestsDirectory)).Return(latestPositiveImageBytes, nil)
- mockMatcherFactory.On("Make", optionalKeys).Return(imgmatching.AlgorithmName("FakeAlgorithm"), fakeMatcher(matcherReturnValue), nil)
-
- matches, err := goldClient.matchImageAgainstBaseline(testName, traceId, imageBytes, digest, optionalKeys)
- assert.NoError(t, err)
- assert.Equal(t, matcherReturnValue, matches)
- })
- }
-
- test("matching algorithm says images match, returns true", true)
- test("matching algorithm says images do not match, returns false", false)
-}
-
func TestCloudClient_GetDigestFromCacheOrGCS_NotInCache_DownloadsImageFromGCS_Success(t *testing.T) {
unittest.MediumTest(t) // This tests reads/writes a small amount of data from/to disk.
diff --git a/gold-client/go/mocks/MatcherFactory.go b/gold-client/go/mocks/MatcherFactory.go
deleted file mode 100644
index 42aa95a..0000000
--- a/gold-client/go/mocks/MatcherFactory.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Code generated by mockery v1.0.0. DO NOT EDIT.
-
-package mocks
-
-import (
- mock "github.com/stretchr/testify/mock"
- imgmatching "go.skia.org/infra/gold-client/go/imgmatching"
-)
-
-// MatcherFactory is an autogenerated mock type for the MatcherFactory type
-type MatcherFactory struct {
- mock.Mock
-}
-
-// Make provides a mock function with given fields: optionalKeys
-func (_m *MatcherFactory) Make(optionalKeys map[string]string) (imgmatching.AlgorithmName, imgmatching.Matcher, error) {
- ret := _m.Called(optionalKeys)
-
- var r0 imgmatching.AlgorithmName
- if rf, ok := ret.Get(0).(func(map[string]string) imgmatching.AlgorithmName); ok {
- r0 = rf(optionalKeys)
- } else {
- r0 = ret.Get(0).(imgmatching.AlgorithmName)
- }
-
- var r1 imgmatching.Matcher
- if rf, ok := ret.Get(1).(func(map[string]string) imgmatching.Matcher); ok {
- r1 = rf(optionalKeys)
- } else {
- if ret.Get(1) != nil {
- r1 = ret.Get(1).(imgmatching.Matcher)
- }
- }
-
- var r2 error
- if rf, ok := ret.Get(2).(func(map[string]string) error); ok {
- r2 = rf(optionalKeys)
- } else {
- r2 = ret.Error(2)
- }
-
- return r0, r1, r2
-}
diff --git a/gold-client/go/mocks/generate.go b/gold-client/go/mocks/generate.go
index 8996764..90f412f 100644
--- a/gold-client/go/mocks/generate.go
+++ b/gold-client/go/mocks/generate.go
@@ -4,4 +4,3 @@
//go:generate mockery -name GCSUploader -dir ../goldclient -output .
//go:generate mockery -name GoldClient -dir ../goldclient -output .
//go:generate mockery -name HTTPClient -dir ../goldclient -output .
-//go:generate mockery -name MatcherFactory -dir ../imgmatching -output .