github.com/please-build/go-rules/tools/please_go@v0.0.0-20240319165128-ea27d6f5caba/modinfo/modinfo_test.go (about)

     1  package modinfo_test
     2  
     3  import (
     4  	"runtime/debug"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestModInfo(t *testing.T) {
    12  	info, ok := debug.ReadBuildInfo()
    13  	require.True(t, ok)
    14  	assert.Equal(t, "github.com/please-build/go-rules/tools/please_go/modinfo", info.Path)
    15  	assert.Equal(t, debug.Module{Path: "github.com/please-build/go-rules"}, info.Main)
    16  	// This lot will change if/when we update versions of these things. That's fine, we just want to assert
    17  	// that there's _something_ sensible in this field.
    18  	assert.Equal(t, []*debug.Module{
    19  		{
    20  			Path:    "github.com/davecgh/go-spew",
    21  			Version: "v1.1.1",
    22  		},
    23  		{
    24  			Path:    "github.com/pmezard/go-difflib",
    25  			Version: "v1.0.0",
    26  		},
    27  		{
    28  			Path:    "github.com/stretchr/testify",
    29  			Version: "v1.7.0",
    30  		},
    31  		{
    32  			Path:    "golang.org/x/mod",
    33  			Version: "v0.16.0",
    34  		},
    35  		{
    36  			Path:    "golang.org/x/xerrors",
    37  			Version: "v0.0.0-20200804184101-5ec99f83aff1",
    38  		},
    39  		{
    40  			Path:    "gopkg.in/yaml.v3",
    41  			Version: "v3.0.0-20210107192922-496545a6307b",
    42  		},
    43  	}, info.Deps)
    44  }