From 40f5fdf15edeb3cc4ccec74eb5d9eb0ea6fccb41 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Thu, 18 Apr 2024 10:08:12 -0700 Subject: [PATCH] Test version --- provider/provider.go | 4 ++-- provider/provider_test.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/provider/provider.go b/provider/provider.go index fe7dcbc..4820e79 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -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 { diff --git a/provider/provider_test.go b/provider/provider_test.go index cf3d4fd..0e18dcb 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -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) +}