From dedeab3c5e169df3413fa387d3f558d0a3883760 Mon Sep 17 00:00:00 2001 From: joeduffy Date: Sun, 11 Jun 2017 08:14:27 -0700 Subject: [PATCH] Update test util to use new packages Also add a license, fix some long lines, and make it gofmt clean. --- lib/aws/provider/testutil/provider.go | 30 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/aws/provider/testutil/provider.go b/lib/aws/provider/testutil/provider.go index 3940b3e4b..fb68c5c2a 100644 --- a/lib/aws/provider/testutil/provider.go +++ b/lib/aws/provider/testutil/provider.go @@ -1,3 +1,18 @@ +// Licensed to Pulumi Corporation ("Pulumi") under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// Pulumi licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package testutil import ( @@ -6,6 +21,7 @@ import ( structpb "github.com/golang/protobuf/ptypes/struct" "github.com/pulumi/lumi/pkg/resource" + "github.com/pulumi/lumi/pkg/resource/plugin" "github.com/pulumi/lumi/pkg/tokens" "github.com/pulumi/lumi/sdk/go/pkg/lumirpc" "github.com/stretchr/testify/assert" @@ -82,12 +98,12 @@ func ProviderTest(t *testing.T, resources map[string]Resource, steps []Step) { } } -// ProviderTestSimple takes a resource provider and array of resource steps and performs a Create, as many Udpates +// ProviderTestSimple takes a resource provider and array of resource steps and performs a Create, as many Updates // as neeed, and finally a Delete operation on a single resouce of the given type to walk the resource through the // resource lifecycle. It also performs Check operations on each input state of the resource. func ProviderTestSimple(t *testing.T, provider lumirpc.ResourceProviderServer, token tokens.Type, steps []interface{}) { resources := map[string]Resource{ - "testResource": Resource{ + "testResource": { Provider: provider, Token: token, }, @@ -123,8 +139,9 @@ func (p *providerTest) GetResourceID(name string) resource.ID { var _ Context = &providerTest{} -func createResource(t *testing.T, res interface{}, provider lumirpc.ResourceProviderServer, token tokens.Type) (string, *structpb.Struct) { - props := resource.MarshalProperties(nil, resource.NewPropertyMap(res), resource.MarshalOptions{}) +func createResource(t *testing.T, res interface{}, provider lumirpc.ResourceProviderServer, + token tokens.Type) (string, *structpb.Struct) { + props := plugin.MarshalProperties(nil, resource.NewPropertyMap(res), plugin.MarshalOptions{}) fmt.Printf("[Provider Test]: Checking %v\n", token) checkResp, err := provider.Check(nil, &lumirpc.CheckRequest{ Type: string(token), @@ -160,8 +177,9 @@ func createResource(t *testing.T, res interface{}, provider lumirpc.ResourceProv return id, props } -func updateResource(t *testing.T, id string, lastProps *structpb.Struct, res interface{}, provider lumirpc.ResourceProviderServer, token tokens.Type) (bool, *structpb.Struct) { - newProps := resource.MarshalProperties(nil, resource.NewPropertyMap(res), resource.MarshalOptions{}) +func updateResource(t *testing.T, id string, lastProps *structpb.Struct, res interface{}, + provider lumirpc.ResourceProviderServer, token tokens.Type) (bool, *structpb.Struct) { + newProps := plugin.MarshalProperties(nil, resource.NewPropertyMap(res), plugin.MarshalOptions{}) fmt.Printf("[Provider Test]: Checking %v\n", token) checkResp, err := provider.Check(nil, &lumirpc.CheckRequest{ Type: string(token),