Skip to content

Commit 68ab937

Browse files
committed
Repair modparser tests
### What does this PR do? Repair the `modparser` tests that were inadvertently broken, and remove unused/outdated `testdata/*/go.sum` files. ### Motivation Offload #45714 which aims at migrating `modparser` as first Go module to `bazel` (better have them individually cherry-pickable/revertable). The tests were broken since #30061 when `require` blocks were removed from `testdata/*/go.mod` files during a dependencies upgrade. As the tests are not yet (or no longer?) running in CI, the breakage went unnoticed. ### Describe how you validated your changes - test failure: `TestFilterMatch/With_matches` expected to find `["github.com/DataDog/datadog-agent/pkg/test"]` but got empty array. All 7/7 test cases now pass. - golangci-lint issues: 2 `perfsprint` violations (`fmt.Errorf` without format specifiers should use `errors.New`). ### Additional Notes #45714 or a follow-up PR will make sure the tests run in CI.
1 parent 3937bbf commit 68ab937

File tree

6 files changed

+14
-29
lines changed

6 files changed

+14
-29
lines changed

internal/tools/modparser/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package main
77

88
import (
9-
"fmt"
9+
"errors"
1010
"testing"
1111

1212
"github.com/stretchr/testify/assert"
@@ -36,12 +36,12 @@ func TestParseMod(t *testing.T) {
3636
{
3737
name: "Missing module",
3838
modPath: "./testdata/nonexistant/",
39-
expectedErr: fmt.Errorf("could not read go.mod file in ./testdata/nonexistant/"),
39+
expectedErr: errors.New("could not read go.mod file in ./testdata/nonexistant/"),
4040
},
4141
{
4242
name: "Badly formatted module",
4343
modPath: "./testdata/badformat/",
44-
expectedErr: fmt.Errorf("could not parse go.mod file in ./testdata/badformat/"),
44+
expectedErr: errors.New("could not parse go.mod file in ./testdata/badformat/"),
4545
},
4646
}
4747

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module github.com/DataDog/datadog-agent/internal/tools/modparser/testdata/match
22

3-
go 1.18
3+
go 1.25.0
4+
5+
require (
6+
github.com/DataDog/datadog-agent/pkg/test v0.65.3
7+
)

internal/tools/modparser/testdata/match/go.sum

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module github.com/DataDog/datadog-agent/internal/tools/modparser/testdata/nomatch
22

3-
go 1.18
3+
go 1.25.0
4+
5+
require (
6+
github.com/DataDog/datadog-not-agent/pkg/test v0.65.3
7+
not/github.com/DataDog/datadog-agent/pkg/test v0.65.3
8+
)

internal/tools/modparser/testdata/nomatch/go.sum

Lines changed: 0 additions & 8 deletions
This file was deleted.

internal/tools/modparser/testdata/patchgoversion/go.sum

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)