Test version

This commit is contained in:
Bryce Lampe
2024-04-18 10:08:12 -07:00
parent b9a801e8ae
commit 40f5fdf15e
2 changed files with 20 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ import (
)
// Version is initialized by the Go linker to contain the semver of this build.
var Version string
var Version = "0.0.1"
// Name needs to match $PACK in Makefile.
const Name string = "docker-build"
@@ -62,7 +62,7 @@ func (p configurableProvider) Configure(
ctx context.Context,
request *rpc.ConfigureRequest,
) (*rpc.ConfigureResponse, error) {
schema := internal.Schema(ctx, "")
schema := internal.Schema(ctx, Version)
ce := deprecated.New(schema.Config)
buildxReq := request
if props, err := ce.UnmarshalProperties(request.Args); err == nil {

View File

@@ -18,8 +18,10 @@ import (
"context"
"testing"
"github.com/blang/semver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
emptypb "google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/structpb"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
@@ -48,3 +50,19 @@ func TestConfigure(t *testing.T) {
assert.NoError(t, err)
}
func TestVersion(t *testing.T) {
t.Parallel()
_, err := semver.Parse(Version)
assert.NoError(t, err)
p, err := New(nil)
require.NoError(t, err)
info, err := p.GetPluginInfo(context.Background(), &emptypb.Empty{})
assert.NoError(t, err)
require.NotEqual(t, "", Version)
assert.Equal(t, Version, info.Version)
}