Skip to content

Commit

Permalink
fetchModule: smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhuravlev committed Jan 3, 2025
1 parent 06d7ebb commit 3c11341
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/workdir/runtimes/runtime-go/private_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os/exec"
"testing"

"github.com/kazhuravlev/toolset/internal/fsh"

"github.com/kazhuravlev/toolset/internal/prog"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -44,3 +46,30 @@ func Test_parse(t *testing.T) {
IsPrivate: false,
})
}

func Test_fetchModule(t *testing.T) {
fs := fsh.NewRealFS()
goBin, err := exec.LookPath("go")
require.NoError(t, err, "install go")

f := func(name, link string, exp moduleInfo) {
t.Run(name, func(t *testing.T) {
ctx := context.Background()
mod, err := fetchModule(ctx, fs, goBin, link)
require.NoError(t, err)
require.NotEmpty(t, mod)
require.Equal(t, exp, *mod)
})
}

f("with_ver", "github.com/bufbuild/buf/cmd/buf@v1.47.2", moduleInfo{
Mod: prog.NewVer("github.com/bufbuild/buf/cmd/buf", "v1.47.2"),
Program: "buf",
IsPrivate: false,
})
f("v2_version", "github.com/goreleaser/goreleaser/v2@v2.5.1", moduleInfo{
Mod: prog.NewVer("github.com/goreleaser/goreleaser/v2", "v2.5.1"),
Program: "goreleaser",
IsPrivate: false,
})
}

0 comments on commit 3c11341

Please # to comment.