Skip to content

Commit

Permalink
Ensure the knative.dev/hack package doesn't have any deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cardil committed Sep 22, 2023
1 parent b823ec5 commit e2833d0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
github.com/stretchr/testify v1.8.1
github.com/thanhpk/randstr v1.0.4
golang.org/x/mod v0.12.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/thanhpk/randstr v1.0.4 h1:IN78qu/bR+My+gHCvMEXhR/i5oriVHcTB/BJJIRTsNo=
github.com/thanhpk/randstr v1.0.4/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
32 changes: 32 additions & 0 deletions test/no_deps_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sample_test

import (
"os"
"testing"

"golang.org/x/mod/modfile"
)

func TestNoDependenciesPresent(t *testing.T) {
var (
bytes []byte
err error
)
if bytes, err = os.ReadFile("../go.mod"); err != nil {
t.Fatal(err)
}

var mf *modfile.File
if mf, err = modfile.ParseLax("go.mod", bytes, nil); err != nil {
t.Fatal(err)
}

if len(mf.Require) > 0 {
deps := make([]string, 0, len(mf.Require))
for _, r := range mf.Require {
deps = append(deps, r.Mod.String())
}
t.Errorf("go.mod file should not have dependencies, but has %d: %+q",
len(mf.Require), deps)
}
}

0 comments on commit e2833d0

Please sign in to comment.