Upgrade go-provider

This commit is contained in:
Bryce Lampe
2024-04-25 16:58:05 -07:00
parent d3e22d5679
commit 63ca9973ae
13 changed files with 85 additions and 549 deletions

View File

@@ -24,9 +24,6 @@ import (
"github.com/docker/docker/api/types/registry"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
)
func TestAuth(t *testing.T) {
@@ -79,18 +76,6 @@ func TestCustomHost(t *testing.T) {
func TestBuild(t *testing.T) {
t.Parallel()
// Workaround for https://github.com/pulumi/pulumi-go-provider/issues/159
ctrl, ctx := gomock.WithContext(context.Background(), t)
pctx := NewMockProviderContext(ctrl)
pctx.EXPECT().Log(gomock.Any(), gomock.Any()).AnyTimes()
pctx.EXPECT().LogStatus(gomock.Any(), gomock.Any()).AnyTimes()
pctx.EXPECT().Done().Return(ctx.Done()).AnyTimes()
pctx.EXPECT().
Value(gomock.Any()).
DoAndReturn(func(key any) any { return ctx.Value(key) }).
AnyTimes()
pctx.EXPECT().Err().Return(ctx.Err()).AnyTimes()
pctx.EXPECT().Deadline().Return(ctx.Deadline()).AnyTimes()
tmpdir := t.TempDir()
max := Max
@@ -300,12 +285,13 @@ func TestBuild(t *testing.T) {
if tt.skip {
t.Skip()
}
ctx := context.Background()
cli := testcli(t, true, tt.auths...)
build, err := tt.args.toBuild(pctx, false)
build, err := tt.args.toBuild(ctx, false)
require.NoError(t, err)
_, err = cli.Build(pctx, build)
_, err = cli.Build(ctx, build)
assert.NoError(t, err, cli.err.String())
})
}
@@ -373,8 +359,6 @@ func TestBuildError(t *testing.T) {
t.Skip("flaky on CI for some reason")
}
ctrl, ctx := gomock.WithContext(context.Background(), t)
exampleContext := &BuildContext{Context: Context{Location: "../../examples/app"}}
args := ImageArgs{
@@ -385,26 +369,13 @@ func TestBuildError(t *testing.T) {
}
logged := bytes.Buffer{}
pctx := NewMockProviderContext(ctrl)
pctx.EXPECT().Done().Return(ctx.Done()).AnyTimes()
pctx.EXPECT().
Value(gomock.Any()).
DoAndReturn(func(key any) any { return ctx.Value(key) }).
AnyTimes()
pctx.EXPECT().Err().Return(ctx.Err()).AnyTimes()
pctx.EXPECT().Deadline().Return(ctx.Deadline()).AnyTimes()
pctx.EXPECT().LogStatus(gomock.Any(), gomock.Any()).AnyTimes()
pctx.EXPECT().Log(gomock.Any(), gomock.Any()).DoAndReturn(func(_ diag.Severity, msg string) {
logged.WriteString(msg)
}).AnyTimes()
ctx := context.Background()
cli := testcli(t, true)
build, err := args.toBuild(pctx, false)
build, err := args.toBuild(ctx, false)
require.NoError(t, err)
_, err = cli.Build(pctx, build)
_, err = cli.Build(ctx, build)
assert.Error(t, err)
want := []string{
@@ -422,7 +393,6 @@ func TestBuildError(t *testing.T) {
func TestBuildExecError(t *testing.T) {
t.Parallel()
ctrl, _ := gomock.WithContext(context.Background(), t)
exampleContext := &BuildContext{Context: Context{Location: "../../examples/app"}}
@@ -434,20 +404,13 @@ func TestBuildExecError(t *testing.T) {
Exec: true,
}
pctx := NewMockProviderContext(ctrl)
pctx.EXPECT().Log(
diag.Warning,
"No exports were specified so the build will only remain in the local build cache. "+
"Use `push` to upload the image to a registry, or silence this warning with a `cacheonly` export.",
)
pctx.EXPECT().LogStatus(gomock.Any(), gomock.Any()).AnyTimes()
ctx := context.Background()
cli := testcli(t, true)
build, err := args.toBuild(pctx, false)
build, err := args.toBuild(ctx, false)
require.NoError(t, err)
_, err = cli.Build(pctx, build)
_, err = cli.Build(ctx, build)
assert.Error(t, err)
want := []string{