Skip to content

Commit

Permalink
test: replace go-test/deep with google/go-cmp (#39902)
Browse files Browse the repository at this point in the history
go-test/deep is only used once and can be safely replaced with
google/go-cmp which is already used for other tests.
The error message changes a bit.

Before:
--- FAIL: TestJsonToSynthEvent (0.00s)
    --- FAIL: TestJsonToSynthEvent/a_valid_line (0.00s)
        synthexec_test.go:94: [TimestampEpochMicros: 7.165676811882693e+18 != 1.7165676811882693e+19]
FAIL
FAIL    github.com/elastic/beats/v7/x-pack/heartbeat/monitors/browser/synthexec 0.180s
FAIL

After:
--- FAIL: TestJsonToSynthEvent (0.00s)
    --- FAIL: TestJsonToSynthEvent/a_valid_line (0.00s)
        synthexec_test.go:95:   &synthexec.SynthEvent{
                ... // 3 identical fields
                Step:                 &{Name: "Go to home page", Status: "succeeded"},
                Journey:              &{Name: "inline", ID: "inline"},
            -   TimestampEpochMicros: 7.165676811882693e+18,
            +   TimestampEpochMicros: 1.7165676811882693e+19,
                Payload:              {"duration_ms": float64(3472), "source": string("async ({page, params}) => {await page.goto('http:
                Blob:                 "",
                ... // 1 ignored and 5 identical fields
              }

FAIL
FAIL    github.com/elastic/beats/v7/x-pack/heartbeat/monitors/browser/synthexec 0.197s
FAIL
  • Loading branch information
kruskall authored Jun 24, 2024
1 parent 8b89f79 commit 40bfa06
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
31 changes: 0 additions & 31 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17002,37 +17002,6 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
defined by the Mozilla Public License, v. 2.0.


--------------------------------------------------------------------------------
Dependency : github.com/go-test/deep
Version: v1.0.7
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/go-test/[email protected]/LICENSE:

MIT License

Copyright 2015-2017 Daniel Nichter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/gocarina/gocsv
Version: v0.0.0-20170324095351-ffef3ffc77be
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ require (
github.com/fsnotify/fsnotify v1.5.1
github.com/go-sourcemap/sourcemap v2.1.2+incompatible // indirect
github.com/go-sql-driver/mysql v1.6.0
github.com/go-test/deep v1.0.7
github.com/gocarina/gocsv v0.0.0-20170324095351-ffef3ffc77be
github.com/godbus/dbus/v5 v5.0.6
github.com/godror/godror v0.33.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,6 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
Expand Down
5 changes: 3 additions & 2 deletions x-pack/heartbeat/monitors/browser/synthexec/synthexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import (
"testing"
"time"

"github.com/go-test/deep"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -90,7 +91,7 @@ func TestJsonToSynthEvent(t *testing.T) {
require.NoError(t, err, "for line %s", tt.line)
}

if diff := deep.Equal(gotRes, tt.synthEvent); diff != nil {
if diff := cmp.Diff(gotRes, tt.synthEvent, cmpopts.IgnoreUnexported(SynthEvent{})); diff != "" {
t.Error(diff)
}
})
Expand Down

0 comments on commit 40bfa06

Please sign in to comment.