From f14f0b5821f037fe4e15ab3623c52e701fbf3a94 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 30 Jan 2024 09:27:29 +0000 Subject: [PATCH 01/12] Adding function tests for framework protocol 5 & 6 and protocol 6 mux providers (#202) --- go.mod | 15 +- go.sum | 30 ++-- internal/framework5provider/bool_function.go | 36 +++++ .../framework5provider/bool_function_test.go | 90 +++++++++++ .../framework5provider/float64_function.go | 36 +++++ .../float64_function_test.go | 90 +++++++++++ internal/framework5provider/int64_function.go | 36 +++++ .../framework5provider/int64_function_test.go | 90 +++++++++++ internal/framework5provider/list_function.go | 41 +++++ .../framework5provider/list_function_test.go | 100 +++++++++++++ internal/framework5provider/map_function.go | 41 +++++ .../framework5provider/map_function_test.go | 106 +++++++++++++ .../framework5provider/number_function.go | 37 +++++ .../number_function_test.go | 106 +++++++++++++ .../framework5provider/object_function.go | 51 +++++++ .../object_function_test.go | 106 +++++++++++++ internal/framework5provider/provider.go | 17 +++ internal/framework5provider/set_function.go | 41 +++++ .../framework5provider/set_function_test.go | 100 +++++++++++++ .../framework5provider/string_function.go | 36 +++++ .../string_function_test.go | 90 +++++++++++ .../framework5provider/variadic_function.go | 37 +++++ .../variadic_function_test.go | 141 ++++++++++++++++++ internal/framework6provider/bool_function.go | 36 +++++ .../framework6provider/bool_function_test.go | 90 +++++++++++ .../framework6provider/float64_function.go | 36 +++++ .../float64_function_test.go | 90 +++++++++++ internal/framework6provider/int64_function.go | 36 +++++ .../framework6provider/int64_function_test.go | 90 +++++++++++ internal/framework6provider/list_function.go | 41 +++++ .../framework6provider/list_function_test.go | 100 +++++++++++++ internal/framework6provider/map_function.go | 41 +++++ .../framework6provider/map_function_test.go | 106 +++++++++++++ .../framework6provider/number_function.go | 37 +++++ .../number_function_test.go | 104 +++++++++++++ .../framework6provider/object_function.go | 51 +++++++ .../object_function_test.go | 106 +++++++++++++ internal/framework6provider/provider.go | 21 +++ internal/framework6provider/set_function.go | 41 +++++ .../framework6provider/set_function_test.go | 100 +++++++++++++ .../framework6provider/string_function.go | 36 +++++ .../string_function_test.go | 90 +++++++++++ .../framework6provider/variadic_function.go | 37 +++++ .../variadic_function_test.go | 141 ++++++++++++++++++ .../tf6muxprovider/provider1/bool_function.go | 36 +++++ .../provider1/bool_function_test.go | 90 +++++++++++ internal/tf6muxprovider/provider1/provider.go | 8 + 47 files changed, 3013 insertions(+), 24 deletions(-) create mode 100644 internal/framework5provider/bool_function.go create mode 100644 internal/framework5provider/bool_function_test.go create mode 100644 internal/framework5provider/float64_function.go create mode 100644 internal/framework5provider/float64_function_test.go create mode 100644 internal/framework5provider/int64_function.go create mode 100644 internal/framework5provider/int64_function_test.go create mode 100644 internal/framework5provider/list_function.go create mode 100644 internal/framework5provider/list_function_test.go create mode 100644 internal/framework5provider/map_function.go create mode 100644 internal/framework5provider/map_function_test.go create mode 100644 internal/framework5provider/number_function.go create mode 100644 internal/framework5provider/number_function_test.go create mode 100644 internal/framework5provider/object_function.go create mode 100644 internal/framework5provider/object_function_test.go create mode 100644 internal/framework5provider/set_function.go create mode 100644 internal/framework5provider/set_function_test.go create mode 100644 internal/framework5provider/string_function.go create mode 100644 internal/framework5provider/string_function_test.go create mode 100644 internal/framework5provider/variadic_function.go create mode 100644 internal/framework5provider/variadic_function_test.go create mode 100644 internal/framework6provider/bool_function.go create mode 100644 internal/framework6provider/bool_function_test.go create mode 100644 internal/framework6provider/float64_function.go create mode 100644 internal/framework6provider/float64_function_test.go create mode 100644 internal/framework6provider/int64_function.go create mode 100644 internal/framework6provider/int64_function_test.go create mode 100644 internal/framework6provider/list_function.go create mode 100644 internal/framework6provider/list_function_test.go create mode 100644 internal/framework6provider/map_function.go create mode 100644 internal/framework6provider/map_function_test.go create mode 100644 internal/framework6provider/number_function.go create mode 100644 internal/framework6provider/number_function_test.go create mode 100644 internal/framework6provider/object_function.go create mode 100644 internal/framework6provider/object_function_test.go create mode 100644 internal/framework6provider/set_function.go create mode 100644 internal/framework6provider/set_function_test.go create mode 100644 internal/framework6provider/string_function.go create mode 100644 internal/framework6provider/string_function_test.go create mode 100644 internal/framework6provider/variadic_function.go create mode 100644 internal/framework6provider/variadic_function_test.go create mode 100644 internal/tf6muxprovider/provider1/bool_function.go create mode 100644 internal/tf6muxprovider/provider1/bool_function_test.go diff --git a/go.mod b/go.mod index 5fcd98e..28fe9f0 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/terraform-plugin-go v0.20.0 github.com/hashicorp/terraform-plugin-mux v0.13.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 - github.com/hashicorp/terraform-plugin-testing v1.6.0 + github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4 ) require ( @@ -24,7 +24,7 @@ require ( github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect @@ -34,8 +34,8 @@ require ( github.com/hashicorp/hc-install v0.6.2 // indirect github.com/hashicorp/hcl/v2 v2.19.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.19.0 // indirect - github.com/hashicorp/terraform-json v0.18.0 // indirect + github.com/hashicorp/terraform-exec v0.20.0 // indirect + github.com/hashicorp/terraform-json v0.21.0 // indirect github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect @@ -51,12 +51,11 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.14.1 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect + github.com/zclconf/go-cty v1.14.2 // indirect + golang.org/x/crypto v0.18.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect diff --git a/go.sum b/go.sum index b3923db..97f8bcd 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.2 h1:NOtoftovWkDheyUM/8JW3QMiXyxJK3uHRK7wV04nD2I= +github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c= @@ -66,10 +66,10 @@ github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5R github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= -github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= -github.com/hashicorp/terraform-json v0.18.0 h1:pCjgJEqqDESv4y0Tzdqfxr/edOIGkjs8keY42xfNBwU= -github.com/hashicorp/terraform-json v0.18.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= +github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= +github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= +github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= +github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= github.com/hashicorp/terraform-plugin-framework v1.5.0 h1:8kcvqJs/x6QyOFSdeAyEgsenVOUeC/IyKpi2ul4fjTg= github.com/hashicorp/terraform-plugin-framework v1.5.0/go.mod h1:6waavirukIlFpVpthbGd2PUNYaFedB0RwW3MDzJ/rtc= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E= @@ -82,8 +82,8 @@ github.com/hashicorp/terraform-plugin-mux v0.13.0 h1:79U401/3nd8CWwDGtTHc8F3miSC github.com/hashicorp/terraform-plugin-mux v0.13.0/go.mod h1:Ndv0FtwDG2ogzH59y64f2NYimFJ6I0smRgFUKfm6dyQ= github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 h1:Bl3e2ei2j/Z3Hc2HIS15Gal2KMKyLAZ2om1HCEvK6es= github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0/go.mod h1:i2C41tszDjiWfziPQDL5R/f3Zp0gahXe5No/MIO9rCE= -github.com/hashicorp/terraform-plugin-testing v1.6.0 h1:Wsnfh+7XSVRfwcr2jZYHsnLOnZl7UeaOBvsx6dl/608= -github.com/hashicorp/terraform-plugin-testing v1.6.0/go.mod h1:cJGG0/8j9XhHaJZRC+0sXFI4uzqQZ9Az4vh6C4GJpFE= +github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4 h1:0KOyDPP1c+nbMY/tJ2To5IVns0pYTWmBLMvCQIuo91Q= +github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4/go.mod h1:sa2XQ3fjHJzpNZqeeSf4FAgr0DWEHHr08OyxMxJBI1M= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -134,16 +134,14 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= -github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= +github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= -golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= @@ -175,8 +173,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= diff --git a/internal/framework5provider/bool_function.go b/internal/framework5provider/bool_function.go new file mode 100644 index 0000000..cab7932 --- /dev/null +++ b/internal/framework5provider/bool_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = BoolFunction{} + +func NewBoolFunction() function.Function { + return &BoolFunction{} +} + +type BoolFunction struct{} + +func (f BoolFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "bool" +} + +func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.BoolParameter{}, + }, + Return: function.BoolReturn{}, + } +} + +func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg bool + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/bool_function_test.go b/internal/framework5provider/bool_function_test.go new file mode 100644 index 0000000..e334148 --- /dev/null +++ b/internal/framework5provider/bool_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestBoolFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::bool(true) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} + +func TestBoolFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::bool(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestBoolFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::bool(true) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/float64_function.go b/internal/framework5provider/float64_function.go new file mode 100644 index 0000000..566f336 --- /dev/null +++ b/internal/framework5provider/float64_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = Float64Function{} + +func NewFloat64Function() function.Function { + return &Float64Function{} +} + +type Float64Function struct{} + +func (f Float64Function) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "float64" +} + +func (f Float64Function) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.Float64Parameter{}, + }, + Return: function.Float64Return{}, + } +} + +func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg float64 + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/float64_function_test.go b/internal/framework5provider/float64_function_test.go new file mode 100644 index 0000000..11dc4e1 --- /dev/null +++ b/internal/framework5provider/float64_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestFloat64Function_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::float64(1.23) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Float64Exact(1.23)), + }, + }, + }, + }) +} + +func TestFloat64Function_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::float64(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestFloat64Function_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::float64(1.23) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Float64Exact(1.23)), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/int64_function.go b/internal/framework5provider/int64_function.go new file mode 100644 index 0000000..06a62e8 --- /dev/null +++ b/internal/framework5provider/int64_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = Int64Function{} + +func NewInt64Function() function.Function { + return &Int64Function{} +} + +type Int64Function struct{} + +func (f Int64Function) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "int64" +} + +func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.Int64Parameter{}, + }, + Return: function.Int64Return{}, + } +} + +func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg int64 + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/int64_function_test.go b/internal/framework5provider/int64_function_test.go new file mode 100644 index 0000000..68539ab --- /dev/null +++ b/internal/framework5provider/int64_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestInt64Function_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::int64(123) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Int64Exact(123)), + }, + }, + }, + }) +} + +func TestInt64Function_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::int64(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestInt64Function_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::int64(123) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Int64Exact(123)), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/list_function.go b/internal/framework5provider/list_function.go new file mode 100644 index 0000000..9943389 --- /dev/null +++ b/internal/framework5provider/list_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = ListFunction{} + +func NewListFunction() function.Function { + return &ListFunction{} +} + +type ListFunction struct{} + +func (f ListFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "list" +} + +func (f ListFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.ListParameter{ + ElementType: types.StringType, + }, + }, + Return: function.ListReturn{ + ElementType: types.StringType, + }, + } +} + +func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg []*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/list_function_test.go b/internal/framework5provider/list_function_test.go new file mode 100644 index 0000000..4520403 --- /dev/null +++ b/internal/framework5provider/list_function_test.go @@ -0,0 +1,100 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestListFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::list(["one", "two"]) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} + +func TestListFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::list(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestListFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::list(["one", "two"]) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/map_function.go b/internal/framework5provider/map_function.go new file mode 100644 index 0000000..ef43bbc --- /dev/null +++ b/internal/framework5provider/map_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = MapFunction{} + +func NewMapFunction() function.Function { + return &MapFunction{} +} + +type MapFunction struct{} + +func (f MapFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "map" +} + +func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.MapParameter{ + ElementType: types.StringType, + }, + }, + Return: function.MapReturn{ + ElementType: types.StringType, + }, + } +} + +func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg map[string]*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/map_function_test.go b/internal/framework5provider/map_function_test.go new file mode 100644 index 0000000..0b8ec35 --- /dev/null +++ b/internal/framework5provider/map_function_test.go @@ -0,0 +1,106 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestMapFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::map({ + "key1" = "value1", + "key2" = "value2", + }) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.MapExact( + map[string]knownvalue.Check{ + "key1": knownvalue.StringExact("value1"), + "key2": knownvalue.StringExact("value2"), + }, + )), + }, + }, + }, + }) +} + +func TestMapFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::map(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestMapFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::map({ + "key1" = "value1", + "key2" = "value2", + }) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.MapExact( + map[string]knownvalue.Check{ + "key1": knownvalue.StringExact("value1"), + "key2": knownvalue.StringExact("value2"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/number_function.go b/internal/framework5provider/number_function.go new file mode 100644 index 0000000..b80d0ae --- /dev/null +++ b/internal/framework5provider/number_function.go @@ -0,0 +1,37 @@ +package framework + +import ( + "context" + "math/big" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = NumberFunction{} + +func NewNumberFunction() function.Function { + return &NumberFunction{} +} + +type NumberFunction struct{} + +func (f NumberFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "number" +} + +func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.NumberParameter{}, + }, + Return: function.NumberReturn{}, + } +} + +func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg *big.Float + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/number_function_test.go b/internal/framework5provider/number_function_test.go new file mode 100644 index 0000000..9511da4 --- /dev/null +++ b/internal/framework5provider/number_function_test.go @@ -0,0 +1,106 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "fmt" + "math/big" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestNumberFunction_known(t *testing.T) { + bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + + if err != nil { + t.Errorf("%s", err) + } + + fmt.Printf("%f", bf) + + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + output "test" { + value = provider::framework::number(%f) + }`, bf), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.NumberExact(bf)), + }, + }, + }, + }) +} + +func TestNumberFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::number(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestNumberFunction_unknown(t *testing.T) { + bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + + if err != nil { + t.Errorf("%s", err) + } + + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + resource "terraform_data" "test" { + input = provider::framework::number(%f) + } + + output "test" { + value = terraform_data.test.output + }`, bf), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.NumberExact(bf)), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/object_function.go b/internal/framework5provider/object_function.go new file mode 100644 index 0000000..f8be7a6 --- /dev/null +++ b/internal/framework5provider/object_function.go @@ -0,0 +1,51 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = ObjectFunction{} + +func NewObjectFunction() function.Function { + return &ObjectFunction{} +} + +type ObjectFunction struct{} + +func (f ObjectFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "object" +} + +func (f ObjectFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.ObjectParameter{ + AttributeTypes: map[string]attr.Type{ + "attr1": types.StringType, + "attr2": types.Int64Type, + }, + }, + }, + Return: function.ObjectReturn{ + AttributeTypes: map[string]attr.Type{ + "attr1": types.StringType, + "attr2": types.Int64Type, + }, + }, + } +} + +func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg struct { + Attr1 *string `tfsdk:"attr1"` + Attr2 *int64 `tfsdk:"attr2"` + } + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/object_function_test.go b/internal/framework5provider/object_function_test.go new file mode 100644 index 0000000..f80f7f2 --- /dev/null +++ b/internal/framework5provider/object_function_test.go @@ -0,0 +1,106 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestObjectFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::object({ + "attr1" = "value1", + "attr2" = 123, + }) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ObjectExact( + map[string]knownvalue.Check{ + "attr1": knownvalue.StringExact("value1"), + "attr2": knownvalue.Int64Exact(123), + }, + )), + }, + }, + }, + }) +} + +func TestObjectFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::object(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestObjectFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::object({ + "attr1" = "value1", + "attr2" = 123, + }) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ObjectExact( + map[string]knownvalue.Check{ + "attr1": knownvalue.StringExact("value1"), + "attr2": knownvalue.Int64Exact(123), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/provider.go b/internal/framework5provider/provider.go index 79eee6f..30637fa 100644 --- a/internal/framework5provider/provider.go +++ b/internal/framework5provider/provider.go @@ -7,9 +7,11 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -53,3 +55,18 @@ func (p *testProvider) Resources(_ context.Context) []func() resource.Resource { func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } + +func (p *testProvider) Functions(ctx context.Context) []func() function.Function { + return []func() function.Function{ + NewBoolFunction, + NewFloat64Function, + NewInt64Function, + NewListFunction, + NewMapFunction, + NewNumberFunction, + NewObjectFunction, + NewSetFunction, + NewStringFunction, + NewVariadicFunction, + } +} diff --git a/internal/framework5provider/set_function.go b/internal/framework5provider/set_function.go new file mode 100644 index 0000000..ff9b205 --- /dev/null +++ b/internal/framework5provider/set_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = SetFunction{} + +func NewSetFunction() function.Function { + return &SetFunction{} +} + +type SetFunction struct{} + +func (f SetFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "set" +} + +func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.SetParameter{ + ElementType: types.StringType, + }, + }, + Return: function.SetReturn{ + ElementType: types.StringType, + }, + } +} + +func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg []*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/set_function_test.go b/internal/framework5provider/set_function_test.go new file mode 100644 index 0000000..cae5ef1 --- /dev/null +++ b/internal/framework5provider/set_function_test.go @@ -0,0 +1,100 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestSetFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::set(["one", "two"]) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.SetExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} + +func TestSetFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::set(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestSetFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::set(["one", "two"]) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.SetExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/string_function.go b/internal/framework5provider/string_function.go new file mode 100644 index 0000000..eb571dd --- /dev/null +++ b/internal/framework5provider/string_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = StringFunction{} + +func NewStringFunction() function.Function { + return &StringFunction{} +} + +type StringFunction struct{} + +func (f StringFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "string" +} + +func (f StringFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.StringParameter{}, + }, + Return: function.StringReturn{}, + } +} + +func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework5provider/string_function_test.go b/internal/framework5provider/string_function_test.go new file mode 100644 index 0000000..31e608d --- /dev/null +++ b/internal/framework5provider/string_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestStringFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::string("test-value") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("test-value")), + }, + }, + }, + }) +} + +func TestStringFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::string(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestStringFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::string("test-value") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("test-value")), + }, + }, + }, + }) +} diff --git a/internal/framework5provider/variadic_function.go b/internal/framework5provider/variadic_function.go new file mode 100644 index 0000000..69aee05 --- /dev/null +++ b/internal/framework5provider/variadic_function.go @@ -0,0 +1,37 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = VariadicFunction{} + +func NewVariadicFunction() function.Function { + return &VariadicFunction{} +} + +type VariadicFunction struct{} + +func (f VariadicFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "variadic" +} + +func (f VariadicFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Return: function.ListReturn{ + ElementType: types.StringType, + }, + VariadicParameter: function.StringParameter{}, + } +} + +func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var varg []string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...) +} diff --git a/internal/framework5provider/variadic_function_test.go b/internal/framework5provider/variadic_function_test.go new file mode 100644 index 0000000..528cd96 --- /dev/null +++ b/internal/framework5provider/variadic_function_test.go @@ -0,0 +1,141 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestVariadicFunction_value_zero(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic() + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{})), + }, + }, + }, + }) +} + +func TestVariadicFunction_value_one(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic("one") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("one"), + })), + }, + }, + }, + }) +} + +func TestVariadicFunction_value_multiple(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic("one", "two") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + })), + }, + }, + }, + }) +} + +func TestVariadicFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestVariadicFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "framework": providerserver.NewProtocol5WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::variadic("test-value") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("test-value"), + })), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/bool_function.go b/internal/framework6provider/bool_function.go new file mode 100644 index 0000000..cab7932 --- /dev/null +++ b/internal/framework6provider/bool_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = BoolFunction{} + +func NewBoolFunction() function.Function { + return &BoolFunction{} +} + +type BoolFunction struct{} + +func (f BoolFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "bool" +} + +func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.BoolParameter{}, + }, + Return: function.BoolReturn{}, + } +} + +func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg bool + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/bool_function_test.go b/internal/framework6provider/bool_function_test.go new file mode 100644 index 0000000..bf2d613 --- /dev/null +++ b/internal/framework6provider/bool_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestBoolFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::bool(true) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} + +func TestBoolFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::bool(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestBoolFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::bool(true) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/float64_function.go b/internal/framework6provider/float64_function.go new file mode 100644 index 0000000..566f336 --- /dev/null +++ b/internal/framework6provider/float64_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = Float64Function{} + +func NewFloat64Function() function.Function { + return &Float64Function{} +} + +type Float64Function struct{} + +func (f Float64Function) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "float64" +} + +func (f Float64Function) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.Float64Parameter{}, + }, + Return: function.Float64Return{}, + } +} + +func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg float64 + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/float64_function_test.go b/internal/framework6provider/float64_function_test.go new file mode 100644 index 0000000..6bdbdcc --- /dev/null +++ b/internal/framework6provider/float64_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestFloat64Function_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::float64(1.23) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Float64Exact(1.23)), + }, + }, + }, + }) +} + +func TestFloat64Function_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::float64(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestFloat64Function_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::float64(1.23) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Float64Exact(1.23)), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/int64_function.go b/internal/framework6provider/int64_function.go new file mode 100644 index 0000000..06a62e8 --- /dev/null +++ b/internal/framework6provider/int64_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = Int64Function{} + +func NewInt64Function() function.Function { + return &Int64Function{} +} + +type Int64Function struct{} + +func (f Int64Function) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "int64" +} + +func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.Int64Parameter{}, + }, + Return: function.Int64Return{}, + } +} + +func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg int64 + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/int64_function_test.go b/internal/framework6provider/int64_function_test.go new file mode 100644 index 0000000..8bb95f2 --- /dev/null +++ b/internal/framework6provider/int64_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestInt64Function_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::int64(123) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Int64Exact(123)), + }, + }, + }, + }) +} + +func TestInt64Function_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::int64(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestInt64Function_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::int64(123) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Int64Exact(123)), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/list_function.go b/internal/framework6provider/list_function.go new file mode 100644 index 0000000..9943389 --- /dev/null +++ b/internal/framework6provider/list_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = ListFunction{} + +func NewListFunction() function.Function { + return &ListFunction{} +} + +type ListFunction struct{} + +func (f ListFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "list" +} + +func (f ListFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.ListParameter{ + ElementType: types.StringType, + }, + }, + Return: function.ListReturn{ + ElementType: types.StringType, + }, + } +} + +func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg []*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/list_function_test.go b/internal/framework6provider/list_function_test.go new file mode 100644 index 0000000..2d50e75 --- /dev/null +++ b/internal/framework6provider/list_function_test.go @@ -0,0 +1,100 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestListFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::list(["one", "two"]) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} + +func TestListFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::list(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestListFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::list(["one", "two"]) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/map_function.go b/internal/framework6provider/map_function.go new file mode 100644 index 0000000..ef43bbc --- /dev/null +++ b/internal/framework6provider/map_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = MapFunction{} + +func NewMapFunction() function.Function { + return &MapFunction{} +} + +type MapFunction struct{} + +func (f MapFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "map" +} + +func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.MapParameter{ + ElementType: types.StringType, + }, + }, + Return: function.MapReturn{ + ElementType: types.StringType, + }, + } +} + +func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg map[string]*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/map_function_test.go b/internal/framework6provider/map_function_test.go new file mode 100644 index 0000000..6341059 --- /dev/null +++ b/internal/framework6provider/map_function_test.go @@ -0,0 +1,106 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestMapFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::map({ + "key1" = "value1", + "key2" = "value2", + }) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.MapExact( + map[string]knownvalue.Check{ + "key1": knownvalue.StringExact("value1"), + "key2": knownvalue.StringExact("value2"), + }, + )), + }, + }, + }, + }) +} + +func TestMapFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::map(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestMapFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::map({ + "key1" = "value1", + "key2" = "value2", + }) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.MapExact( + map[string]knownvalue.Check{ + "key1": knownvalue.StringExact("value1"), + "key2": knownvalue.StringExact("value2"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/number_function.go b/internal/framework6provider/number_function.go new file mode 100644 index 0000000..b80d0ae --- /dev/null +++ b/internal/framework6provider/number_function.go @@ -0,0 +1,37 @@ +package framework + +import ( + "context" + "math/big" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = NumberFunction{} + +func NewNumberFunction() function.Function { + return &NumberFunction{} +} + +type NumberFunction struct{} + +func (f NumberFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "number" +} + +func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.NumberParameter{}, + }, + Return: function.NumberReturn{}, + } +} + +func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg *big.Float + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/number_function_test.go b/internal/framework6provider/number_function_test.go new file mode 100644 index 0000000..a56764e --- /dev/null +++ b/internal/framework6provider/number_function_test.go @@ -0,0 +1,104 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "fmt" + "math/big" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestNumberFunction_known(t *testing.T) { + bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + + if err != nil { + t.Errorf("%s", err) + } + + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::number(9223372036854775808) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.NumberExact(bf)), + }, + }, + }, + }) +} + +func TestNumberFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::number(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestNumberFunction_unknown(t *testing.T) { + bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + + if err != nil { + t.Errorf("%s", err) + } + + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + resource "terraform_data" "test" { + input = provider::framework::number(%f) + } + + output "test" { + value = terraform_data.test.output + }`, bf), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.NumberExact(bf)), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/object_function.go b/internal/framework6provider/object_function.go new file mode 100644 index 0000000..f8be7a6 --- /dev/null +++ b/internal/framework6provider/object_function.go @@ -0,0 +1,51 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = ObjectFunction{} + +func NewObjectFunction() function.Function { + return &ObjectFunction{} +} + +type ObjectFunction struct{} + +func (f ObjectFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "object" +} + +func (f ObjectFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.ObjectParameter{ + AttributeTypes: map[string]attr.Type{ + "attr1": types.StringType, + "attr2": types.Int64Type, + }, + }, + }, + Return: function.ObjectReturn{ + AttributeTypes: map[string]attr.Type{ + "attr1": types.StringType, + "attr2": types.Int64Type, + }, + }, + } +} + +func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg struct { + Attr1 *string `tfsdk:"attr1"` + Attr2 *int64 `tfsdk:"attr2"` + } + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/object_function_test.go b/internal/framework6provider/object_function_test.go new file mode 100644 index 0000000..be34a9e --- /dev/null +++ b/internal/framework6provider/object_function_test.go @@ -0,0 +1,106 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestObjectFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::object({ + "attr1" = "value1", + "attr2" = 123, + }) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ObjectExact( + map[string]knownvalue.Check{ + "attr1": knownvalue.StringExact("value1"), + "attr2": knownvalue.Int64Exact(123), + }, + )), + }, + }, + }, + }) +} + +func TestObjectFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::object(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestObjectFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::object({ + "attr1" = "value1", + "attr2" = 123, + }) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ObjectExact( + map[string]knownvalue.Check{ + "attr1": knownvalue.StringExact("value1"), + "attr2": knownvalue.Int64Exact(123), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/provider.go b/internal/framework6provider/provider.go index 79eee6f..493467f 100644 --- a/internal/framework6provider/provider.go +++ b/internal/framework6provider/provider.go @@ -7,12 +7,18 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) +var ( + _ provider.ProviderWithFunctions = (*testProvider)(nil) +) + func New() provider.Provider { return &testProvider{} } @@ -53,3 +59,18 @@ func (p *testProvider) Resources(_ context.Context) []func() resource.Resource { func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } + +func (p *testProvider) Functions(ctx context.Context) []func() function.Function { + return []func() function.Function{ + NewBoolFunction, + NewFloat64Function, + NewInt64Function, + NewListFunction, + NewMapFunction, + NewNumberFunction, + NewObjectFunction, + NewSetFunction, + NewStringFunction, + NewVariadicFunction, + } +} diff --git a/internal/framework6provider/set_function.go b/internal/framework6provider/set_function.go new file mode 100644 index 0000000..ff9b205 --- /dev/null +++ b/internal/framework6provider/set_function.go @@ -0,0 +1,41 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = SetFunction{} + +func NewSetFunction() function.Function { + return &SetFunction{} +} + +type SetFunction struct{} + +func (f SetFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "set" +} + +func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.SetParameter{ + ElementType: types.StringType, + }, + }, + Return: function.SetReturn{ + ElementType: types.StringType, + }, + } +} + +func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg []*string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/set_function_test.go b/internal/framework6provider/set_function_test.go new file mode 100644 index 0000000..68eefd2 --- /dev/null +++ b/internal/framework6provider/set_function_test.go @@ -0,0 +1,100 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestSetFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::set(["one", "two"]) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.SetExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} + +func TestSetFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::set(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestSetFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::set(["one", "two"]) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.SetExact( + []knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + }, + )), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/string_function.go b/internal/framework6provider/string_function.go new file mode 100644 index 0000000..eb571dd --- /dev/null +++ b/internal/framework6provider/string_function.go @@ -0,0 +1,36 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = StringFunction{} + +func NewStringFunction() function.Function { + return &StringFunction{} +} + +type StringFunction struct{} + +func (f StringFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "string" +} + +func (f StringFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.StringParameter{}, + }, + Return: function.StringReturn{}, + } +} + +func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/framework6provider/string_function_test.go b/internal/framework6provider/string_function_test.go new file mode 100644 index 0000000..9b4eb1e --- /dev/null +++ b/internal/framework6provider/string_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestStringFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::string("test-value") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("test-value")), + }, + }, + }, + }) +} + +func TestStringFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::string(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestStringFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::string("test-value") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("test-value")), + }, + }, + }, + }) +} diff --git a/internal/framework6provider/variadic_function.go b/internal/framework6provider/variadic_function.go new file mode 100644 index 0000000..69aee05 --- /dev/null +++ b/internal/framework6provider/variadic_function.go @@ -0,0 +1,37 @@ +package framework + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ function.Function = VariadicFunction{} + +func NewVariadicFunction() function.Function { + return &VariadicFunction{} +} + +type VariadicFunction struct{} + +func (f VariadicFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "variadic" +} + +func (f VariadicFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Return: function.ListReturn{ + ElementType: types.StringType, + }, + VariadicParameter: function.StringParameter{}, + } +} + +func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var varg []string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...) +} diff --git a/internal/framework6provider/variadic_function_test.go b/internal/framework6provider/variadic_function_test.go new file mode 100644 index 0000000..d3b8004 --- /dev/null +++ b/internal/framework6provider/variadic_function_test.go @@ -0,0 +1,141 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package framework + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestVariadicFunction_value_zero(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic() + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{})), + }, + }, + }, + }) +} + +func TestVariadicFunction_value_one(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic("one") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("one"), + })), + }, + }, + }, + }) +} + +func TestVariadicFunction_value_multiple(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic("one", "two") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("one"), + knownvalue.StringExact("two"), + })), + }, + }, + }, + }) +} + +func TestVariadicFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::framework::variadic(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestVariadicFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "framework": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::framework::variadic("test-value") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.ListExact([]knownvalue.Check{ + knownvalue.StringExact("test-value"), + })), + }, + }, + }, + }) +} diff --git a/internal/tf6muxprovider/provider1/bool_function.go b/internal/tf6muxprovider/provider1/bool_function.go new file mode 100644 index 0000000..34388cd --- /dev/null +++ b/internal/tf6muxprovider/provider1/bool_function.go @@ -0,0 +1,36 @@ +package provider1 + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = BoolFunction{} + +func NewBoolFunction() function.Function { + return &BoolFunction{} +} + +type BoolFunction struct{} + +func (f BoolFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "bool" +} + +func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.BoolParameter{}, + }, + Return: function.BoolReturn{}, + } +} + +func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg bool + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/tf6muxprovider/provider1/bool_function_test.go b/internal/tf6muxprovider/provider1/bool_function_test.go new file mode 100644 index 0000000..02dd977 --- /dev/null +++ b/internal/tf6muxprovider/provider1/bool_function_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider1 + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestBoolFunction_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6muxprovider::bool(true) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} + +func TestBoolFunction_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6muxprovider::bool(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestBoolFunction_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::tf6muxprovider::bool(true) + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} diff --git a/internal/tf6muxprovider/provider1/provider.go b/internal/tf6muxprovider/provider1/provider.go index f274c27..c4c87e1 100644 --- a/internal/tf6muxprovider/provider1/provider.go +++ b/internal/tf6muxprovider/provider1/provider.go @@ -7,9 +7,11 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -50,3 +52,9 @@ func (p *testProvider) Resources(_ context.Context) []func() resource.Resource { func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } + +func (p *testProvider) Functions(ctx context.Context) []func() function.Function { + return []func() function.Function{ + NewBoolFunction, + } +} From 77f2277dcce573d27853b91796f173ef60a05e38 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 30 Jan 2024 09:32:54 +0000 Subject: [PATCH 02/12] Adding copyright headers (#202) --- internal/framework5provider/bool_function.go | 3 +++ internal/framework5provider/float64_function.go | 3 +++ internal/framework5provider/int64_function.go | 3 +++ internal/framework5provider/list_function.go | 3 +++ internal/framework5provider/map_function.go | 3 +++ internal/framework5provider/number_function.go | 3 +++ internal/framework5provider/object_function.go | 3 +++ internal/framework5provider/set_function.go | 3 +++ internal/framework5provider/string_function.go | 3 +++ internal/framework5provider/variadic_function.go | 3 +++ internal/framework6provider/bool_function.go | 3 +++ internal/framework6provider/float64_function.go | 3 +++ internal/framework6provider/int64_function.go | 3 +++ internal/framework6provider/list_function.go | 3 +++ internal/framework6provider/map_function.go | 3 +++ internal/framework6provider/number_function.go | 3 +++ internal/framework6provider/object_function.go | 3 +++ internal/framework6provider/set_function.go | 3 +++ internal/framework6provider/string_function.go | 3 +++ internal/framework6provider/variadic_function.go | 3 +++ internal/tf6muxprovider/provider1/bool_function.go | 3 +++ 21 files changed, 63 insertions(+) diff --git a/internal/framework5provider/bool_function.go b/internal/framework5provider/bool_function.go index cab7932..352498f 100644 --- a/internal/framework5provider/bool_function.go +++ b/internal/framework5provider/bool_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/float64_function.go b/internal/framework5provider/float64_function.go index 566f336..a51c5e7 100644 --- a/internal/framework5provider/float64_function.go +++ b/internal/framework5provider/float64_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/int64_function.go b/internal/framework5provider/int64_function.go index 06a62e8..3c9cfc2 100644 --- a/internal/framework5provider/int64_function.go +++ b/internal/framework5provider/int64_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/list_function.go b/internal/framework5provider/list_function.go index 9943389..b0e7006 100644 --- a/internal/framework5provider/list_function.go +++ b/internal/framework5provider/list_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/map_function.go b/internal/framework5provider/map_function.go index ef43bbc..9cbce0b 100644 --- a/internal/framework5provider/map_function.go +++ b/internal/framework5provider/map_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/number_function.go b/internal/framework5provider/number_function.go index b80d0ae..9faeacc 100644 --- a/internal/framework5provider/number_function.go +++ b/internal/framework5provider/number_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/object_function.go b/internal/framework5provider/object_function.go index f8be7a6..ca63ea8 100644 --- a/internal/framework5provider/object_function.go +++ b/internal/framework5provider/object_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/set_function.go b/internal/framework5provider/set_function.go index ff9b205..453e5ca 100644 --- a/internal/framework5provider/set_function.go +++ b/internal/framework5provider/set_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/string_function.go b/internal/framework5provider/string_function.go index eb571dd..ea46dc6 100644 --- a/internal/framework5provider/string_function.go +++ b/internal/framework5provider/string_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework5provider/variadic_function.go b/internal/framework5provider/variadic_function.go index 69aee05..92f4b12 100644 --- a/internal/framework5provider/variadic_function.go +++ b/internal/framework5provider/variadic_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/bool_function.go b/internal/framework6provider/bool_function.go index cab7932..352498f 100644 --- a/internal/framework6provider/bool_function.go +++ b/internal/framework6provider/bool_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/float64_function.go b/internal/framework6provider/float64_function.go index 566f336..a51c5e7 100644 --- a/internal/framework6provider/float64_function.go +++ b/internal/framework6provider/float64_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/int64_function.go b/internal/framework6provider/int64_function.go index 06a62e8..3c9cfc2 100644 --- a/internal/framework6provider/int64_function.go +++ b/internal/framework6provider/int64_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/list_function.go b/internal/framework6provider/list_function.go index 9943389..b0e7006 100644 --- a/internal/framework6provider/list_function.go +++ b/internal/framework6provider/list_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/map_function.go b/internal/framework6provider/map_function.go index ef43bbc..9cbce0b 100644 --- a/internal/framework6provider/map_function.go +++ b/internal/framework6provider/map_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/number_function.go b/internal/framework6provider/number_function.go index b80d0ae..9faeacc 100644 --- a/internal/framework6provider/number_function.go +++ b/internal/framework6provider/number_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/object_function.go b/internal/framework6provider/object_function.go index f8be7a6..ca63ea8 100644 --- a/internal/framework6provider/object_function.go +++ b/internal/framework6provider/object_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/set_function.go b/internal/framework6provider/set_function.go index ff9b205..453e5ca 100644 --- a/internal/framework6provider/set_function.go +++ b/internal/framework6provider/set_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/string_function.go b/internal/framework6provider/string_function.go index eb571dd..ea46dc6 100644 --- a/internal/framework6provider/string_function.go +++ b/internal/framework6provider/string_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/framework6provider/variadic_function.go b/internal/framework6provider/variadic_function.go index 69aee05..92f4b12 100644 --- a/internal/framework6provider/variadic_function.go +++ b/internal/framework6provider/variadic_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package framework import ( diff --git a/internal/tf6muxprovider/provider1/bool_function.go b/internal/tf6muxprovider/provider1/bool_function.go index 34388cd..273a070 100644 --- a/internal/tf6muxprovider/provider1/bool_function.go +++ b/internal/tf6muxprovider/provider1/bool_function.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package provider1 import ( From 6653ce64a3bee80442252a7bfad6355d26ee07a0 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 30 Jan 2024 10:38:01 +0000 Subject: [PATCH 03/12] Linting (#202) --- .../float64_precision_resource_test.go | 4 +++ .../framework5provider/resource_user_test.go | 5 +++ .../schema_resource_test.go | 25 ++++++++++++++ .../timeouts_resource_test.go | 2 ++ .../float64_precision_resource_test.go | 4 +++ .../framework6provider/resource_user_test.go | 5 +++ .../schema_resource_test.go | 33 +++++++++++++++++++ .../timeouts_resource_test.go | 2 ++ internal/protocolprovider/data_time_test.go | 1 + internal/protocolv6provider/data_time_test.go | 1 + .../sdkv2provider/data_source_bigint_test.go | 1 + .../data_source_regions_cty_test.go | 1 + .../sdkv2provider/data_source_regions_test.go | 1 + .../sdkv2provider/resource_bigint_test.go | 1 + .../sdkv2provider/resource_user_cty_test.go | 2 ++ internal/sdkv2provider/resource_user_test.go | 1 + .../data_source_bigint_test.go | 1 + .../data_source_regions_cty_test.go | 1 + .../data_source_regions_test.go | 1 + .../resource_bigint_test.go | 1 + .../resource_user_cty_test.go | 2 ++ .../resource_user_test.go | 1 + .../provider1/resource_user_test.go | 1 + .../provider2/resource_user_test.go | 1 + internal/tf5muxprovider/provider_test.go | 1 + .../provider/resource_user_test.go | 1 + internal/tf5to6provider/provider_test.go | 1 + .../provider1/resource_user_test.go | 1 + .../provider2/resource_user_test.go | 1 + internal/tf6muxprovider/provider_test.go | 1 + .../provider/resource_user_test.go | 1 + internal/tf6to5provider/provider_test.go | 1 + 32 files changed, 106 insertions(+) diff --git a/internal/framework5provider/float64_precision_resource_test.go b/internal/framework5provider/float64_precision_resource_test.go index 7e83d81..a9ae29f 100644 --- a/internal/framework5provider/float64_precision_resource_test.go +++ b/internal/framework5provider/float64_precision_resource_test.go @@ -24,6 +24,7 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.99 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), @@ -32,6 +33,7 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.98 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006"), ), @@ -52,6 +54,7 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 0.01 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.01"), ), @@ -65,6 +68,7 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { plancheck.ExpectNonEmptyPlan(), }, }, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), diff --git a/internal/framework5provider/resource_user_test.go b/internal/framework5provider/resource_user_test.go index d5dfe95..dae2826 100644 --- a/internal/framework5provider/resource_user_test.go +++ b/internal/framework5provider/resource_user_test.go @@ -19,6 +19,7 @@ func TestAccFrameworkResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -44,6 +45,7 @@ func TestAccFrameworkResourceUser_language(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserLanguage, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "J Doe"), @@ -74,6 +76,7 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -89,6 +92,7 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { }, { Config: configResourceUserLanguageInterpolated, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -130,6 +134,7 @@ resource "framework_user" "test" { id = "h" } `, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_user.test", "name", expectedUserName), ), diff --git a/internal/framework5provider/schema_resource_test.go b/internal/framework5provider/schema_resource_test.go index 2f22778..3a7fe11 100644 --- a/internal/framework5provider/schema_resource_test.go +++ b/internal/framework5provider/schema_resource_test.go @@ -19,6 +19,7 @@ func TestSchemaResource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_schema" "test" {}`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -49,6 +50,7 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = true }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "true"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -69,6 +71,7 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = false }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "false"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -99,6 +102,7 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 1234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "1234.5"), @@ -119,6 +123,7 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 2234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "2234.5"), @@ -149,6 +154,7 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 1234 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -169,6 +175,7 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 2345 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -199,6 +206,7 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value1"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -220,6 +228,7 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value2"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -253,6 +262,7 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -276,6 +286,7 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -309,6 +320,7 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -332,6 +344,7 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -363,6 +376,7 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 1234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -383,6 +397,7 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 2234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -415,6 +430,7 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -437,6 +453,7 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -467,6 +484,7 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value1"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -488,6 +506,7 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value2"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -521,6 +540,7 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -546,6 +566,7 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -581,6 +602,7 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -603,6 +625,7 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -633,6 +656,7 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value1" }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -653,6 +677,7 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value2" }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), diff --git a/internal/framework5provider/timeouts_resource_test.go b/internal/framework5provider/timeouts_resource_test.go index 05d4e76..c067ed9 100644 --- a/internal/framework5provider/timeouts_resource_test.go +++ b/internal/framework5provider/timeouts_resource_test.go @@ -19,6 +19,7 @@ func TestTimeoutsResource_unconfigured(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_timeouts" "test" {}`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckNoResourceAttr("framework_timeouts.test", "timeouts"), @@ -40,6 +41,7 @@ func TestTimeoutsResource_configured(t *testing.T) { create = "120s" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckResourceAttr("framework_timeouts.test", "timeouts.create", "120s"), diff --git a/internal/framework6provider/float64_precision_resource_test.go b/internal/framework6provider/float64_precision_resource_test.go index ea92b8d..6deccaa 100644 --- a/internal/framework6provider/float64_precision_resource_test.go +++ b/internal/framework6provider/float64_precision_resource_test.go @@ -24,6 +24,7 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.99 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), @@ -32,6 +33,7 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.98 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006"), ), @@ -52,6 +54,7 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 0.01 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.01"), ), @@ -65,6 +68,7 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { plancheck.ExpectNonEmptyPlan(), }, }, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), diff --git a/internal/framework6provider/resource_user_test.go b/internal/framework6provider/resource_user_test.go index 352c91f..329428f 100644 --- a/internal/framework6provider/resource_user_test.go +++ b/internal/framework6provider/resource_user_test.go @@ -19,6 +19,7 @@ func TestAccFrameworkResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -44,6 +45,7 @@ func TestAccFrameworkResourceUser_language(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserLanguage, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "J Doe"), @@ -74,6 +76,7 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -89,6 +92,7 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { }, { Config: configResourceUserLanguageInterpolated, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -130,6 +134,7 @@ resource "framework_user" "test" { id = "h" } `, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_user.test", "name", expectedUserName), ), diff --git a/internal/framework6provider/schema_resource_test.go b/internal/framework6provider/schema_resource_test.go index 1245246..5ab2ef0 100644 --- a/internal/framework6provider/schema_resource_test.go +++ b/internal/framework6provider/schema_resource_test.go @@ -19,6 +19,7 @@ func TestSchemaResource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_schema" "test" {}`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -53,6 +54,7 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = true }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "true"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -77,6 +79,7 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = false }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "false"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -111,6 +114,7 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 1234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "1234.5"), @@ -135,6 +139,7 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 2234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "2234.5"), @@ -169,6 +174,7 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 1234 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -193,6 +199,7 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 2345 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -227,6 +234,7 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value1"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -252,6 +260,7 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value2"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -291,6 +300,7 @@ func TestSchemaResource_ListNestedAttribute(t *testing.T) { }, ] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -320,6 +330,7 @@ func TestSchemaResource_ListNestedAttribute(t *testing.T) { }, ] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -357,6 +368,7 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -384,6 +396,7 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -421,6 +434,7 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -448,6 +462,7 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -487,6 +502,7 @@ func TestSchemaResource_MapNestedAttribute(t *testing.T) { }, } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -516,6 +532,7 @@ func TestSchemaResource_MapNestedAttribute(t *testing.T) { }, } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -551,6 +568,7 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 1234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -575,6 +593,7 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 2234.5 }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -611,6 +630,7 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -637,6 +657,7 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -671,6 +692,7 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value1"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -696,6 +718,7 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value2"] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -735,6 +758,7 @@ func TestSchemaResource_SetNestedAttribute(t *testing.T) { }, ] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -766,6 +790,7 @@ func TestSchemaResource_SetNestedAttribute(t *testing.T) { }, ] }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -805,6 +830,7 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -834,6 +860,7 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -873,6 +900,7 @@ func TestSchemaResource_SingleNestedAttribute(t *testing.T) { single_nested_attribute_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -899,6 +927,7 @@ func TestSchemaResource_SingleNestedAttribute(t *testing.T) { single_nested_attribute_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -935,6 +964,7 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value1" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -961,6 +991,7 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value2" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -995,6 +1026,7 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value1" }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -1019,6 +1051,7 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value2" }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), diff --git a/internal/framework6provider/timeouts_resource_test.go b/internal/framework6provider/timeouts_resource_test.go index 0f17d25..8857b20 100644 --- a/internal/framework6provider/timeouts_resource_test.go +++ b/internal/framework6provider/timeouts_resource_test.go @@ -19,6 +19,7 @@ func TestTimeoutsResource_unconfigured(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_timeouts" "test" {}`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckNoResourceAttr("framework_timeouts.test", "timeouts"), @@ -40,6 +41,7 @@ func TestTimeoutsResource_configured(t *testing.T) { create = "120s" } }`, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckResourceAttr("framework_timeouts.test", "timeouts.create", "120s"), diff --git a/internal/protocolprovider/data_time_test.go b/internal/protocolprovider/data_time_test.go index 841e41d..949a9ed 100644 --- a/internal/protocolprovider/data_time_test.go +++ b/internal/protocolprovider/data_time_test.go @@ -22,6 +22,7 @@ func TestAccDataSourceTime(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDataSourceTimeConfig, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("data.corner_time.foo", "current", regexp.MustCompile(`[0-9]+`)), ), diff --git a/internal/protocolv6provider/data_time_test.go b/internal/protocolv6provider/data_time_test.go index 33e0e1b..c93422d 100644 --- a/internal/protocolv6provider/data_time_test.go +++ b/internal/protocolv6provider/data_time_test.go @@ -22,6 +22,7 @@ func TestAccV6DataSourceTime(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDataSourceTimeConfig, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("data.corner_v6_time.foo", "current", regexp.MustCompile(`[0-9]+`)), ), diff --git a/internal/sdkv2provider/data_source_bigint_test.go b/internal/sdkv2provider/data_source_bigint_test.go index f9bf15e..89e68ff 100644 --- a/internal/sdkv2provider/data_source_bigint_test.go +++ b/internal/sdkv2provider/data_source_bigint_test.go @@ -16,6 +16,7 @@ func testAccDataSourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBigint, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.corner_bigint.foo", "int64", "7227701560655103598")), }, diff --git a/internal/sdkv2provider/data_source_regions_cty_test.go b/internal/sdkv2provider/data_source_regions_cty_test.go index b987f09..463dec5 100644 --- a/internal/sdkv2provider/data_source_regions_cty_test.go +++ b/internal/sdkv2provider/data_source_regions_cty_test.go @@ -16,6 +16,7 @@ func testAccDataSourceRegionsCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceRegionsCtyBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions_cty.foo", "names.#")), }, diff --git a/internal/sdkv2provider/data_source_regions_test.go b/internal/sdkv2provider/data_source_regions_test.go index e094f5b..260ef30 100644 --- a/internal/sdkv2provider/data_source_regions_test.go +++ b/internal/sdkv2provider/data_source_regions_test.go @@ -16,6 +16,7 @@ func testAccDataSourceRegions(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions.foo", "names.#")), }, diff --git a/internal/sdkv2provider/resource_bigint_test.go b/internal/sdkv2provider/resource_bigint_test.go index 041f0ea..a2a8e33 100644 --- a/internal/sdkv2provider/resource_bigint_test.go +++ b/internal/sdkv2provider/resource_bigint_test.go @@ -16,6 +16,7 @@ func testAccResourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBigint, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("corner_bigint.foo", "number", "7227701560655103598"), resource.TestCheckResourceAttr("corner_bigint.foo", "int64", "7227701560655103598"), diff --git a/internal/sdkv2provider/resource_user_cty_test.go b/internal/sdkv2provider/resource_user_cty_test.go index a5b74c5..c80dc35 100644 --- a/internal/sdkv2provider/resource_user_cty_test.go +++ b/internal/sdkv2provider/resource_user_cty_test.go @@ -16,6 +16,7 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceUserCtyBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), @@ -27,6 +28,7 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { }, { Config: configResourceUserCtyUpdate, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), diff --git a/internal/sdkv2provider/resource_user_test.go b/internal/sdkv2provider/resource_user_test.go index a068358..8fb4737 100644 --- a/internal/sdkv2provider/resource_user_test.go +++ b/internal/sdkv2provider/resource_user_test.go @@ -17,6 +17,7 @@ func testAccResourceUser(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr( "corner_user.foo", "name", regexp.MustCompile("^For")), diff --git a/internal/sdkv2testingprovider/data_source_bigint_test.go b/internal/sdkv2testingprovider/data_source_bigint_test.go index 63a40d0..9cc336f 100644 --- a/internal/sdkv2testingprovider/data_source_bigint_test.go +++ b/internal/sdkv2testingprovider/data_source_bigint_test.go @@ -16,6 +16,7 @@ func testAccDataSourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBigint, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.corner_bigint.foo", "int64", "7227701560655103598")), }, diff --git a/internal/sdkv2testingprovider/data_source_regions_cty_test.go b/internal/sdkv2testingprovider/data_source_regions_cty_test.go index 7b0df7d..6350a48 100644 --- a/internal/sdkv2testingprovider/data_source_regions_cty_test.go +++ b/internal/sdkv2testingprovider/data_source_regions_cty_test.go @@ -16,6 +16,7 @@ func testAccDataSourceRegionsCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceRegionsCtyBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions_cty.foo", "names.#")), }, diff --git a/internal/sdkv2testingprovider/data_source_regions_test.go b/internal/sdkv2testingprovider/data_source_regions_test.go index 39081d9..d2278c7 100644 --- a/internal/sdkv2testingprovider/data_source_regions_test.go +++ b/internal/sdkv2testingprovider/data_source_regions_test.go @@ -16,6 +16,7 @@ func testAccDataSourceRegions(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions.foo", "names.#")), }, diff --git a/internal/sdkv2testingprovider/resource_bigint_test.go b/internal/sdkv2testingprovider/resource_bigint_test.go index 4eafb16..f6e8361 100644 --- a/internal/sdkv2testingprovider/resource_bigint_test.go +++ b/internal/sdkv2testingprovider/resource_bigint_test.go @@ -16,6 +16,7 @@ func testAccResourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBigint, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("corner_bigint.foo", "number", "7227701560655103598"), resource.TestCheckResourceAttr("corner_bigint.foo", "int64", "7227701560655103598"), diff --git a/internal/sdkv2testingprovider/resource_user_cty_test.go b/internal/sdkv2testingprovider/resource_user_cty_test.go index f92a73b..bfe066e 100644 --- a/internal/sdkv2testingprovider/resource_user_cty_test.go +++ b/internal/sdkv2testingprovider/resource_user_cty_test.go @@ -16,6 +16,7 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceUserCtyBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), @@ -27,6 +28,7 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { }, { Config: configResourceUserCtyUpdate, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), diff --git a/internal/sdkv2testingprovider/resource_user_test.go b/internal/sdkv2testingprovider/resource_user_test.go index 34c73e0..87e21e2 100644 --- a/internal/sdkv2testingprovider/resource_user_test.go +++ b/internal/sdkv2testingprovider/resource_user_test.go @@ -17,6 +17,7 @@ func testAccResourceUser(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr( "corner_user.foo", "name", regexp.MustCompile("^For")), diff --git a/internal/tf5muxprovider/provider1/resource_user_test.go b/internal/tf5muxprovider/provider1/resource_user_test.go index 647cac1..a26a708 100644 --- a/internal/tf5muxprovider/provider1/resource_user_test.go +++ b/internal/tf5muxprovider/provider1/resource_user_test.go @@ -16,6 +16,7 @@ func TestAccResourceUser1(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5muxprovider_user1.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5muxprovider/provider2/resource_user_test.go b/internal/tf5muxprovider/provider2/resource_user_test.go index 2d91044..ef2ca8a 100644 --- a/internal/tf5muxprovider/provider2/resource_user_test.go +++ b/internal/tf5muxprovider/provider2/resource_user_test.go @@ -16,6 +16,7 @@ func TestAccResourceUser2(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5muxprovider_user2.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5muxprovider/provider_test.go b/internal/tf5muxprovider/provider_test.go index ef2b5dc..fcac80d 100644 --- a/internal/tf5muxprovider/provider_test.go +++ b/internal/tf5muxprovider/provider_test.go @@ -22,6 +22,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf5muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf5muxprovider_user1.example", "email", "example1@example.com"), diff --git a/internal/tf5to6provider/provider/resource_user_test.go b/internal/tf5to6provider/provider/resource_user_test.go index f3e98d1..297ecfb 100644 --- a/internal/tf5to6provider/provider/resource_user_test.go +++ b/internal/tf5to6provider/provider/resource_user_test.go @@ -16,6 +16,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5to6provider_user.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5to6provider/provider_test.go b/internal/tf5to6provider/provider_test.go index 1f0f708..df9c8e3 100644 --- a/internal/tf5to6provider/provider_test.go +++ b/internal/tf5to6provider/provider_test.go @@ -22,6 +22,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf5to6provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf5to6provider_user.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider1/resource_user_test.go b/internal/tf6muxprovider/provider1/resource_user_test.go index 97bf105..c06bf7d 100644 --- a/internal/tf6muxprovider/provider1/resource_user_test.go +++ b/internal/tf6muxprovider/provider1/resource_user_test.go @@ -19,6 +19,7 @@ func TestAccResourceUser1(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider2/resource_user_test.go b/internal/tf6muxprovider/provider2/resource_user_test.go index 196a05a..21cdf78 100644 --- a/internal/tf6muxprovider/provider2/resource_user_test.go +++ b/internal/tf6muxprovider/provider2/resource_user_test.go @@ -19,6 +19,7 @@ func TestAccResourceUser2(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user2.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user2.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider_test.go b/internal/tf6muxprovider/provider_test.go index ea4c65f..75bd97d 100644 --- a/internal/tf6muxprovider/provider_test.go +++ b/internal/tf6muxprovider/provider_test.go @@ -22,6 +22,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "email", "example1@example.com"), diff --git a/internal/tf6to5provider/provider/resource_user_test.go b/internal/tf6to5provider/provider/resource_user_test.go index 026ee77..19c3fad 100644 --- a/internal/tf6to5provider/provider/resource_user_test.go +++ b/internal/tf6to5provider/provider/resource_user_test.go @@ -19,6 +19,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6to5provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf6to5provider_user.example", "email", "example@example.com"), diff --git a/internal/tf6to5provider/provider_test.go b/internal/tf6to5provider/provider_test.go index bdb9152..d84dbb3 100644 --- a/internal/tf6to5provider/provider_test.go +++ b/internal/tf6to5provider/provider_test.go @@ -22,6 +22,7 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, + //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6to5provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf6to5provider_user.example", "email", "example@example.com"), From 9ddc3606ad0bce4c590c38aa891b220c543837b0 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Feb 2024 09:28:42 +0000 Subject: [PATCH 04/12] Adding function tests for protocol v5 and protocol v6 providers (#202) --- internal/protocolprovider/function_bool.go | 29 +++++++++++++++ .../protocolprovider/function_bool_test.go | 36 +++++++++++++++++++ internal/protocolprovider/function_router.go | 32 +++++++++++++++++ internal/protocolprovider/server.go | 20 +++++++++++ internal/protocolv6provider/function_bool.go | 29 +++++++++++++++ .../protocolv6provider/function_bool_test.go | 36 +++++++++++++++++++ .../protocolv6provider/function_router.go | 32 +++++++++++++++++ internal/protocolv6provider/server.go | 20 +++++++++++ 8 files changed, 234 insertions(+) create mode 100644 internal/protocolprovider/function_bool.go create mode 100644 internal/protocolprovider/function_bool_test.go create mode 100644 internal/protocolprovider/function_router.go create mode 100644 internal/protocolv6provider/function_bool.go create mode 100644 internal/protocolv6provider/function_bool_test.go create mode 100644 internal/protocolv6provider/function_router.go diff --git a/internal/protocolprovider/function_bool.go b/internal/protocolprovider/function_bool.go new file mode 100644 index 0000000..0abd2db --- /dev/null +++ b/internal/protocolprovider/function_bool.go @@ -0,0 +1,29 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package protocol + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +type functionBool struct{} + +func (f functionBool) CallFunction(context.Context, *tfprotov5.CallFunctionRequest) (*tfprotov5.CallFunctionResponse, error) { + value, err := tfprotov5.NewDynamicValue(tftypes.Bool, tftypes.NewValue(tftypes.Bool, true)) + + if err != nil { + return nil, err + } + + return &tfprotov5.CallFunctionResponse{ + Result: &value, + }, nil +} + +func (f functionBool) GetFunctions(context.Context, *tfprotov5.GetFunctionsRequest) (*tfprotov5.GetFunctionsResponse, error) { + panic("implement me") +} diff --git a/internal/protocolprovider/function_bool_test.go b/internal/protocolprovider/function_bool_test.go new file mode 100644 index 0000000..cafac06 --- /dev/null +++ b/internal/protocolprovider/function_bool_test.go @@ -0,0 +1,36 @@ +package protocol + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestAccV5FunctionBool(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + //nolint:unparam // False positive in unparam related to map: https://github.com/mvdan/unparam/issues/40 + "corner": func() (tfprotov5.ProviderServer, error) { + return Server(), nil + }, + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::corner::bool(true) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} diff --git a/internal/protocolprovider/function_router.go b/internal/protocolprovider/function_router.go new file mode 100644 index 0000000..a39568c --- /dev/null +++ b/internal/protocolprovider/function_router.go @@ -0,0 +1,32 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package protocol + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov5" +) + +type errUnsupportedFunction string + +func (e errUnsupportedFunction) Error() string { + return "unsupported function: " + string(e) +} + +type functionRouter map[string]tfprotov5.FunctionServer + +func (f functionRouter) CallFunction(ctx context.Context, req *tfprotov5.CallFunctionRequest) (*tfprotov5.CallFunctionResponse, error) { + fu, ok := f[req.Name] + + if !ok { + return nil, errUnsupportedFunction(req.Name) + } + + return fu.CallFunction(ctx, req) +} + +func (f functionRouter) GetFunctions(ctx context.Context, req *tfprotov5.GetFunctionsRequest) (*tfprotov5.GetFunctionsResponse, error) { + panic("not implemented") +} diff --git a/internal/protocolprovider/server.go b/internal/protocolprovider/server.go index d907f71..2fde318 100644 --- a/internal/protocolprovider/server.go +++ b/internal/protocolprovider/server.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tftypes" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -17,9 +18,11 @@ type server struct { providerMetaSchema *tfprotov5.Schema resourceSchemas map[string]*tfprotov5.Schema dataSourceSchemas map[string]*tfprotov5.Schema + functions map[string]*tfprotov5.Function resourceRouter dataSourceRouter + functionRouter client *backend.Client } @@ -59,6 +62,7 @@ func (s *server) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProvid ResourceSchemas: s.resourceSchemas, DataSourceSchemas: s.dataSourceSchemas, ServerCapabilities: s.serverCapabilities(), + Functions: s.functions, }, nil } @@ -117,5 +121,21 @@ func Server() tfprotov5.ProviderServer { dataSourceRouter: dataSourceRouter{ "corner_time": dataSourceTime{}, }, + functions: map[string]*tfprotov5.Function{ + "bool": { + Parameters: []*tfprotov5.FunctionParameter{ + { + Name: "param", + Type: tftypes.Bool, + }, + }, + Return: &tfprotov5.FunctionReturn{ + Type: tftypes.Bool, + }, + }, + }, + functionRouter: functionRouter{ + "bool": functionBool{}, + }, } } diff --git a/internal/protocolv6provider/function_bool.go b/internal/protocolv6provider/function_bool.go new file mode 100644 index 0000000..cde44a8 --- /dev/null +++ b/internal/protocolv6provider/function_bool.go @@ -0,0 +1,29 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package protocolv6 + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tftypes" +) + +type functionBool struct{} + +func (f functionBool) CallFunction(context.Context, *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error) { + value, err := tfprotov6.NewDynamicValue(tftypes.Bool, tftypes.NewValue(tftypes.Bool, true)) + + if err != nil { + return nil, err + } + + return &tfprotov6.CallFunctionResponse{ + Result: &value, + }, nil +} + +func (f functionBool) GetFunctions(context.Context, *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error) { + panic("implement me") +} diff --git a/internal/protocolv6provider/function_bool_test.go b/internal/protocolv6provider/function_bool_test.go new file mode 100644 index 0000000..bd86c6d --- /dev/null +++ b/internal/protocolv6provider/function_bool_test.go @@ -0,0 +1,36 @@ +package protocolv6 + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestAccV6FunctionBool(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + //nolint:unparam // False positive in unparam related to map: https://github.com/mvdan/unparam/issues/40 + "corner": func() (tfprotov6.ProviderServer, error) { + return Server(), nil + }, + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::corner::bool(true) + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + }, + }, + }, + }) +} diff --git a/internal/protocolv6provider/function_router.go b/internal/protocolv6provider/function_router.go new file mode 100644 index 0000000..c2f8f40 --- /dev/null +++ b/internal/protocolv6provider/function_router.go @@ -0,0 +1,32 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package protocolv6 + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov6" +) + +type errUnsupportedFunction string + +func (e errUnsupportedFunction) Error() string { + return "unsupported function: " + string(e) +} + +type functionRouter map[string]tfprotov6.FunctionServer + +func (f functionRouter) CallFunction(ctx context.Context, req *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error) { + fu, ok := f[req.Name] + + if !ok { + return nil, errUnsupportedFunction(req.Name) + } + + return fu.CallFunction(ctx, req) +} + +func (f functionRouter) GetFunctions(ctx context.Context, req *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error) { + panic("not implemented") +} diff --git a/internal/protocolv6provider/server.go b/internal/protocolv6provider/server.go index 54329b0..30cb092 100644 --- a/internal/protocolv6provider/server.go +++ b/internal/protocolv6provider/server.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -17,9 +18,11 @@ type server struct { providerMetaSchema *tfprotov6.Schema resourceSchemas map[string]*tfprotov6.Schema dataSourceSchemas map[string]*tfprotov6.Schema + functions map[string]*tfprotov6.Function resourceRouter dataSourceRouter + functionRouter client *backend.Client } @@ -59,6 +62,7 @@ func (s *server) GetProviderSchema(ctx context.Context, req *tfprotov6.GetProvid ResourceSchemas: s.resourceSchemas, DataSourceSchemas: s.dataSourceSchemas, ServerCapabilities: s.serverCapabilities(), + Functions: s.functions, }, nil } @@ -117,5 +121,21 @@ func Server() tfprotov6.ProviderServer { dataSourceRouter: dataSourceRouter{ "corner_v6_time": dataSourceTime{}, }, + functions: map[string]*tfprotov6.Function{ + "bool": { + Parameters: []*tfprotov6.FunctionParameter{ + { + Name: "param", + Type: tftypes.Bool, + }, + }, + Return: &tfprotov6.FunctionReturn{ + Type: tftypes.Bool, + }, + }, + }, + functionRouter: functionRouter{ + "bool": functionBool{}, + }, } } From 4565386f1abd58cd10354f3e67c50e660428b604 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Feb 2024 09:51:34 +0000 Subject: [PATCH 05/12] Amending provider defined function tests for number until bug fix on go.cty is released (#202) --- .../number_function_test.go | 20 ++++++++++++---- .../number_function_test.go | 24 +++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/internal/framework5provider/number_function_test.go b/internal/framework5provider/number_function_test.go index 9511da4..4ab9ab4 100644 --- a/internal/framework5provider/number_function_test.go +++ b/internal/framework5provider/number_function_test.go @@ -19,14 +19,19 @@ import ( ) func TestNumberFunction_known(t *testing.T) { - bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + // Using 9223372036854775808, the smallest number that can't be represented as an int64, + // results in an Terraform error where [Planned value does not match config value for cty.NumberIntVal], + // which is related to a bug in go.cty relating to [Large integer comparisons and msgpack encoding]. + // A value of 9223372036854775809 is used for the meanwhile. + // + // [Planned value does not match config value for cty.NumberIntVal]: https://github.com/hashicorp/terraform/issues/34589 + // [Large integer comparisons and msgpack encoding]: https://github.com/zclconf/go-cty/pull/176 + bf, _, err := big.ParseFloat("9223372036854775809", 10, 512, big.ToNearestEven) if err != nil { t.Errorf("%s", err) } - fmt.Printf("%f", bf) - resource.UnitTest(t, resource.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_8_0), @@ -69,7 +74,14 @@ func TestNumberFunction_null(t *testing.T) { } func TestNumberFunction_unknown(t *testing.T) { - bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + // Using 9223372036854775808, the smallest number that can't be represented as an int64, + // results in an Terraform error where [Planned value does not match config value for cty.NumberIntVal], + // which is related to a bug in go.cty relating to [Large integer comparisons and msgpack encoding]. + // A value of 9223372036854775809 is used for the meanwhile. + // + // [Planned value does not match config value for cty.NumberIntVal]: https://github.com/hashicorp/terraform/issues/34589 + // [Large integer comparisons and msgpack encoding]: https://github.com/zclconf/go-cty/pull/176 + bf, _, err := big.ParseFloat("9223372036854775809", 10, 512, big.ToNearestEven) if err != nil { t.Errorf("%s", err) diff --git a/internal/framework6provider/number_function_test.go b/internal/framework6provider/number_function_test.go index a56764e..0b72379 100644 --- a/internal/framework6provider/number_function_test.go +++ b/internal/framework6provider/number_function_test.go @@ -19,7 +19,14 @@ import ( ) func TestNumberFunction_known(t *testing.T) { - bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + // Using 9223372036854775808, the smallest number that can't be represented as an int64, + // results in an Terraform error where [Planned value does not match config value for cty.NumberIntVal], + // which is related to a bug in go.cty relating to [Large integer comparisons and msgpack encoding]. + // A value of 9223372036854775809 is used for the meanwhile. + // + // [Planned value does not match config value for cty.NumberIntVal]: https://github.com/hashicorp/terraform/issues/34589 + // [Large integer comparisons and msgpack encoding]: https://github.com/zclconf/go-cty/pull/176 + bf, _, err := big.ParseFloat("9223372036854775809", 10, 512, big.ToNearestEven) if err != nil { t.Errorf("%s", err) @@ -34,10 +41,10 @@ func TestNumberFunction_known(t *testing.T) { }, Steps: []resource.TestStep{ { - Config: ` + Config: fmt.Sprintf(` output "test" { - value = provider::framework::number(9223372036854775808) - }`, + value = provider::framework::number(%f) + }`, bf), ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownOutputValue("test", knownvalue.NumberExact(bf)), }, @@ -67,7 +74,14 @@ func TestNumberFunction_null(t *testing.T) { } func TestNumberFunction_unknown(t *testing.T) { - bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) + // Using 9223372036854775808, the smallest number that can't be represented as an int64, + // results in an Terraform error where [Planned value does not match config value for cty.NumberIntVal], + // which is related to a bug in go.cty relating to [Large integer comparisons and msgpack encoding]. + // A value of 9223372036854775809 is used for the meanwhile. + // + // [Planned value does not match config value for cty.NumberIntVal]: https://github.com/hashicorp/terraform/issues/34589 + // [Large integer comparisons and msgpack encoding]: https://github.com/zclconf/go-cty/pull/176 + bf, _, err := big.ParseFloat("9223372036854775809", 10, 512, big.ToNearestEven) if err != nil { t.Errorf("%s", err) From 0daf85a4a3a24dd242587be389a7ffb560231dcb Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Feb 2024 10:27:35 +0000 Subject: [PATCH 06/12] Adding function testing for mux providers (#202) --- .../tf6muxprovider/provider1/bool_function.go | 39 -------- .../provider1/function_string.go | 39 ++++++++ ...nction_test.go => function_string_test.go} | 16 ++-- internal/tf6muxprovider/provider1/provider.go | 2 +- .../provider2/function_string.go | 39 ++++++++ .../provider2/function_string_test.go | 90 +++++++++++++++++++ internal/tf6muxprovider/provider2/provider.go | 8 ++ internal/tf6muxprovider/provider_test.go | 34 +++++++ 8 files changed, 219 insertions(+), 48 deletions(-) delete mode 100644 internal/tf6muxprovider/provider1/bool_function.go create mode 100644 internal/tf6muxprovider/provider1/function_string.go rename internal/tf6muxprovider/provider1/{bool_function_test.go => function_string_test.go} (82%) create mode 100644 internal/tf6muxprovider/provider2/function_string.go create mode 100644 internal/tf6muxprovider/provider2/function_string_test.go diff --git a/internal/tf6muxprovider/provider1/bool_function.go b/internal/tf6muxprovider/provider1/bool_function.go deleted file mode 100644 index 273a070..0000000 --- a/internal/tf6muxprovider/provider1/bool_function.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package provider1 - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = BoolFunction{} - -func NewBoolFunction() function.Function { - return &BoolFunction{} -} - -type BoolFunction struct{} - -func (f BoolFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = "bool" -} - -func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Parameters: []function.Parameter{ - function.BoolParameter{}, - }, - Return: function.BoolReturn{}, - } -} - -func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - var arg bool - - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) - - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) -} diff --git a/internal/tf6muxprovider/provider1/function_string.go b/internal/tf6muxprovider/provider1/function_string.go new file mode 100644 index 0000000..0a1cca4 --- /dev/null +++ b/internal/tf6muxprovider/provider1/function_string.go @@ -0,0 +1,39 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider1 + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = StringFunction{} + +func NewStringFunction() function.Function { + return &StringFunction{} +} + +type StringFunction struct{} + +func (f StringFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "string1" +} + +func (f StringFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.StringParameter{}, + }, + Return: function.StringReturn{}, + } +} + +func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/tf6muxprovider/provider1/bool_function_test.go b/internal/tf6muxprovider/provider1/function_string_test.go similarity index 82% rename from internal/tf6muxprovider/provider1/bool_function_test.go rename to internal/tf6muxprovider/provider1/function_string_test.go index 02dd977..6128226 100644 --- a/internal/tf6muxprovider/provider1/bool_function_test.go +++ b/internal/tf6muxprovider/provider1/function_string_test.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/tfversion" ) -func TestBoolFunction_known(t *testing.T) { +func TestFunctionString_known(t *testing.T) { resource.UnitTest(t, resource.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_8_0), @@ -28,17 +28,17 @@ func TestBoolFunction_known(t *testing.T) { { Config: ` output "test" { - value = provider::tf6muxprovider::bool(true) + value = provider::tf6muxprovider::string1("str1") }`, ConfigStateChecks: []statecheck.StateCheck{ - statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str1")), }, }, }, }) } -func TestBoolFunction_null(t *testing.T) { +func TestFunctionString_null(t *testing.T) { resource.UnitTest(t, resource.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_8_0), @@ -50,7 +50,7 @@ func TestBoolFunction_null(t *testing.T) { { Config: ` output "test" { - value = provider::tf6muxprovider::bool(null) + value = provider::tf6muxprovider::string1(null) }`, ExpectError: regexp.MustCompile("Invalid function argument"), }, @@ -58,7 +58,7 @@ func TestBoolFunction_null(t *testing.T) { }) } -func TestBoolFunction_unknown(t *testing.T) { +func TestFunctionString_unknown(t *testing.T) { resource.UnitTest(t, resource.TestCase{ TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.SkipBelow(tfversion.Version1_8_0), @@ -70,7 +70,7 @@ func TestBoolFunction_unknown(t *testing.T) { { Config: ` resource "terraform_data" "test" { - input = provider::tf6muxprovider::bool(true) + input = provider::tf6muxprovider::string1("str1") } output "test" { @@ -82,7 +82,7 @@ func TestBoolFunction_unknown(t *testing.T) { }, }, ConfigStateChecks: []statecheck.StateCheck{ - statecheck.ExpectKnownOutputValue("test", knownvalue.Bool(true)), + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str1")), }, }, }, diff --git a/internal/tf6muxprovider/provider1/provider.go b/internal/tf6muxprovider/provider1/provider.go index c4c87e1..5fa2b6e 100644 --- a/internal/tf6muxprovider/provider1/provider.go +++ b/internal/tf6muxprovider/provider1/provider.go @@ -55,6 +55,6 @@ func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSo func (p *testProvider) Functions(ctx context.Context) []func() function.Function { return []func() function.Function{ - NewBoolFunction, + NewStringFunction, } } diff --git a/internal/tf6muxprovider/provider2/function_string.go b/internal/tf6muxprovider/provider2/function_string.go new file mode 100644 index 0000000..bdded42 --- /dev/null +++ b/internal/tf6muxprovider/provider2/function_string.go @@ -0,0 +1,39 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider2 + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = StringFunction{} + +func NewStringFunction() function.Function { + return &StringFunction{} +} + +type StringFunction struct{} + +func (f StringFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "string2" +} + +func (f StringFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.StringParameter{}, + }, + Return: function.StringReturn{}, + } +} + +func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/tf6muxprovider/provider2/function_string_test.go b/internal/tf6muxprovider/provider2/function_string_test.go new file mode 100644 index 0000000..e81cc45 --- /dev/null +++ b/internal/tf6muxprovider/provider2/function_string_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider2 + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestFunctionString_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6muxprovider::string2("str2") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str2")), + }, + }, + }, + }) +} + +func TestFunctionString_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6muxprovider::string2(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestFunctionString_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::tf6muxprovider::string2("str2") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str2")), + }, + }, + }, + }) +} diff --git a/internal/tf6muxprovider/provider2/provider.go b/internal/tf6muxprovider/provider2/provider.go index 8197547..98f066d 100644 --- a/internal/tf6muxprovider/provider2/provider.go +++ b/internal/tf6muxprovider/provider2/provider.go @@ -7,9 +7,11 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -50,3 +52,9 @@ func (p *testProvider) Resources(_ context.Context) []func() resource.Resource { func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } + +func (p *testProvider) Functions(ctx context.Context) []func() function.Function { + return []func() function.Function{ + NewStringFunction, + } +} diff --git a/internal/tf6muxprovider/provider_test.go b/internal/tf6muxprovider/provider_test.go index 75bd97d..3c866be 100644 --- a/internal/tf6muxprovider/provider_test.go +++ b/internal/tf6muxprovider/provider_test.go @@ -8,6 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAccResourceUser(t *testing.T) { @@ -55,3 +58,34 @@ resource "tf6muxprovider_user2" "example" { name = "Example Name 2" } ` + +func TestAccFunctionString(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6muxprovider": func() (tfprotov6.ProviderServer, error) { + provider, err := New() + + return provider(), err + }, + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test1" { + value = provider::tf6muxprovider::string1("str1") + } + + output "test2" { + value = provider::tf6muxprovider::string2("str2") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test1", knownvalue.StringExact("str1")), + statecheck.ExpectKnownOutputValue("test2", knownvalue.StringExact("str2")), + }, + }, + }, + }) +} From 7587ea01e2b0135f403f7d7b8ff7c99f6963cbfc Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Feb 2024 10:46:49 +0000 Subject: [PATCH 07/12] Adding function testing for tf6to5provider (#202) --- .../provider/function_string.go | 39 ++++++++ .../provider/function_string_test.go | 90 +++++++++++++++++++ internal/tf6to5provider/provider/provider.go | 8 ++ internal/tf6to5provider/provider_test.go | 29 ++++++ 4 files changed, 166 insertions(+) create mode 100644 internal/tf6to5provider/provider/function_string.go create mode 100644 internal/tf6to5provider/provider/function_string_test.go diff --git a/internal/tf6to5provider/provider/function_string.go b/internal/tf6to5provider/provider/function_string.go new file mode 100644 index 0000000..53b7be9 --- /dev/null +++ b/internal/tf6to5provider/provider/function_string.go @@ -0,0 +1,39 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/function" +) + +var _ function.Function = StringFunction{} + +func NewStringFunction() function.Function { + return &StringFunction{} +} + +type StringFunction struct{} + +func (f StringFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { + resp.Name = "string" +} + +func (f StringFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { + resp.Definition = function.Definition{ + Parameters: []function.Parameter{ + function.StringParameter{}, + }, + Return: function.StringReturn{}, + } +} + +func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { + var arg string + + resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + + resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) +} diff --git a/internal/tf6to5provider/provider/function_string_test.go b/internal/tf6to5provider/provider/function_string_test.go new file mode 100644 index 0000000..41ee290 --- /dev/null +++ b/internal/tf6to5provider/provider/function_string_test.go @@ -0,0 +1,90 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" +) + +func TestFunctionString_known(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6to5provider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6to5provider::string("str") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str")), + }, + }, + }, + }) +} + +func TestFunctionString_null(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6to5provider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test" { + value = provider::tf6to5provider::string(null) + }`, + ExpectError: regexp.MustCompile("Invalid function argument"), + }, + }, + }) +} + +func TestFunctionString_unknown(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "tf6to5provider": providerserver.NewProtocol6WithError(New()), + }, + Steps: []resource.TestStep{ + { + Config: ` + resource "terraform_data" "test" { + input = provider::tf6to5provider::string("str") + } + + output "test" { + value = terraform_data.test.output + }`, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectUnknownOutputValue("test"), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test", knownvalue.StringExact("str")), + }, + }, + }, + }) +} diff --git a/internal/tf6to5provider/provider/provider.go b/internal/tf6to5provider/provider/provider.go index 14c9f46..ca998cb 100644 --- a/internal/tf6to5provider/provider/provider.go +++ b/internal/tf6to5provider/provider/provider.go @@ -7,9 +7,11 @@ import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-provider-corner/internal/backend" ) @@ -50,3 +52,9 @@ func (p *testProvider) Resources(_ context.Context) []func() resource.Resource { func (p *testProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } + +func (p *testProvider) Functions(ctx context.Context) []func() function.Function { + return []func() function.Function{ + NewStringFunction, + } +} diff --git a/internal/tf6to5provider/provider_test.go b/internal/tf6to5provider/provider_test.go index d84dbb3..c98770f 100644 --- a/internal/tf6to5provider/provider_test.go +++ b/internal/tf6to5provider/provider_test.go @@ -8,6 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/statecheck" + "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAccResourceUser(t *testing.T) { @@ -43,3 +46,29 @@ resource "tf6to5provider_user" "example" { name = "Example Name" } ` + +func TestAccFunctionString(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.SkipBelow(tfversion.Version1_8_0), + }, + ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){ + "tf6to5provider": func() (tfprotov5.ProviderServer, error) { + provider, err := New() + + return provider(), err + }, + }, + Steps: []resource.TestStep{ + { + Config: ` + output "test1" { + value = provider::tf6to5provider::string("str") + }`, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownOutputValue("test1", knownvalue.StringExact("str")), + }, + }, + }, + }) +} From df39faf4464a0ef5f3d97d9164e4715faa2d5eff Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 1 Feb 2024 10:48:25 +0000 Subject: [PATCH 08/12] Adding copyright headers (#202) --- internal/protocolprovider/function_bool_test.go | 3 +++ internal/protocolv6provider/function_bool_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/internal/protocolprovider/function_bool_test.go b/internal/protocolprovider/function_bool_test.go index cafac06..b26c98c 100644 --- a/internal/protocolprovider/function_bool_test.go +++ b/internal/protocolprovider/function_bool_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package protocol import ( diff --git a/internal/protocolv6provider/function_bool_test.go b/internal/protocolv6provider/function_bool_test.go index bd86c6d..7ddf569 100644 --- a/internal/protocolv6provider/function_bool_test.go +++ b/internal/protocolv6provider/function_bool_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package protocolv6 import ( From 5805816e579523a94b50c08adcb1da12f5bdc0ca Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Thu, 22 Feb 2024 07:41:22 +0000 Subject: [PATCH 09/12] Bumping terraform-plugin-framework version to latest (#202) Latest terraform-plugin-framework contains fix for: * hashicorp/terraform-plugin-framework#914 * hashicorp/terraform-plugin-framework#919 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d1d364e..67f3538 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/hashicorp/go-memdb v1.3.4 - github.com/hashicorp/terraform-plugin-framework v1.5.0 + github.com/hashicorp/terraform-plugin-framework v1.5.1-0.20240222064911-3c7a391644c7 github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 github.com/hashicorp/terraform-plugin-go v0.21.0 github.com/hashicorp/terraform-plugin-mux v0.14.0 diff --git a/go.sum b/go.sum index 9fc9c3a..fb0ba4c 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8J github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= -github.com/hashicorp/terraform-plugin-framework v1.5.0 h1:8kcvqJs/x6QyOFSdeAyEgsenVOUeC/IyKpi2ul4fjTg= -github.com/hashicorp/terraform-plugin-framework v1.5.0/go.mod h1:6waavirukIlFpVpthbGd2PUNYaFedB0RwW3MDzJ/rtc= +github.com/hashicorp/terraform-plugin-framework v1.5.1-0.20240222064911-3c7a391644c7 h1:N6GRbTpkdjMS7xJgF/LEFPuWom0KmU97LWzV+sQXN1o= +github.com/hashicorp/terraform-plugin-framework v1.5.1-0.20240222064911-3c7a391644c7/go.mod h1:amVE1JI/p8KAr0o1HP9CQQserrw7RRkw724oPv9Xql4= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY= github.com/hashicorp/terraform-plugin-go v0.21.0 h1:VSjdVQYNDKR0l2pi3vsFK1PdMQrw6vGOshJXMNFeVc0= From 5a20d7eb61af579a92e2b8cc66f187b393d3a196 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 5 Mar 2024 16:58:13 +0000 Subject: [PATCH 10/12] Bumping terraform-plugin-testing to v1.7.0 (#202) --- go.mod | 13 +++++++------ go.sum | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index ccfefe0..6d06d57 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/terraform-plugin-go v0.22.0 github.com/hashicorp/terraform-plugin-mux v0.15.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4 + github.com/hashicorp/terraform-plugin-testing v1.7.0 ) require ( @@ -34,7 +34,7 @@ require ( github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hc-install v0.6.3 // indirect - github.com/hashicorp/hcl/v2 v2.19.1 // indirect + github.com/hashicorp/hcl/v2 v2.20.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.20.0 // indirect github.com/hashicorp/terraform-json v0.21.0 // indirect @@ -53,12 +53,13 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.14.2 // indirect - golang.org/x/crypto v0.19.0 // indirect + github.com/zclconf/go-cty v1.14.3 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.13.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/grpc v1.62.0 // indirect diff --git a/go.sum b/go.sum index df28d47..be33b99 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+l github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hc-install v0.6.3 h1:yE/r1yJvWbtrJ0STwScgEnCanb0U9v7zp0Gbkmcoxqs= github.com/hashicorp/hc-install v0.6.3/go.mod h1:KamGdbodYzlufbWh4r9NRo8y6GLHWZP2GBtdnms1Ln0= -github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= -github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.20.0 h1:l++cRs/5jQOiKVvqXZm/P1ZEfVXJmvLS9WSVxkaeTb4= +github.com/hashicorp/hcl/v2 v2.20.0/go.mod h1:WmcD/Ym72MDOOx5F62Ly+leloeu6H7m0pG7VBiU6pQk= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= @@ -91,8 +91,8 @@ github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9 github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= -github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4 h1:0KOyDPP1c+nbMY/tJ2To5IVns0pYTWmBLMvCQIuo91Q= -github.com/hashicorp/terraform-plugin-testing v1.6.1-0.20240124164911-4164c30db2a4/go.mod h1:sa2XQ3fjHJzpNZqeeSf4FAgr0DWEHHr08OyxMxJBI1M= +github.com/hashicorp/terraform-plugin-testing v1.7.0 h1:I6aeCyZ30z4NiI3tzyDoO6fS7YxP5xSL1ceOon3gTe8= +github.com/hashicorp/terraform-plugin-testing v1.7.0/go.mod h1:sbAreCleJNOCz+y5vVHV8EJkIWZKi/t4ndKiUjM9vao= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -154,12 +154,12 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= -github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.3 h1:1JXy1XroaGrzZuG6X9dt7HL6s9AwbY+l4UNL8o5B6ho= +github.com/zclconf/go-cty v1.14.3/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= @@ -167,11 +167,13 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -184,8 +186,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 3e3bab5c5ccc27a30361fa1cb885d72344c8bb44 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Tue, 5 Mar 2024 17:09:36 +0000 Subject: [PATCH 11/12] Refactoring to return function.FuncError (#202) --- internal/framework5provider/bool_function.go | 4 ++-- internal/framework5provider/float64_function.go | 4 ++-- internal/framework5provider/int64_function.go | 4 ++-- internal/framework5provider/list_function.go | 4 ++-- internal/framework5provider/map_function.go | 4 ++-- internal/framework5provider/number_function.go | 4 ++-- internal/framework5provider/object_function.go | 4 ++-- internal/framework5provider/set_function.go | 4 ++-- internal/framework5provider/string_function.go | 4 ++-- internal/framework5provider/variadic_function.go | 4 ++-- internal/framework6provider/bool_function.go | 4 ++-- internal/framework6provider/float64_function.go | 4 ++-- internal/framework6provider/int64_function.go | 4 ++-- internal/framework6provider/list_function.go | 4 ++-- internal/framework6provider/map_function.go | 4 ++-- internal/framework6provider/number_function.go | 4 ++-- internal/framework6provider/object_function.go | 4 ++-- internal/framework6provider/set_function.go | 4 ++-- internal/framework6provider/string_function.go | 4 ++-- internal/framework6provider/variadic_function.go | 4 ++-- internal/tf6muxprovider/provider1/function_string.go | 4 ++-- internal/tf6muxprovider/provider2/function_string.go | 4 ++-- internal/tf6to5provider/provider/function_string.go | 4 ++-- 23 files changed, 46 insertions(+), 46 deletions(-) diff --git a/internal/framework5provider/bool_function.go b/internal/framework5provider/bool_function.go index 352498f..844904e 100644 --- a/internal/framework5provider/bool_function.go +++ b/internal/framework5provider/bool_function.go @@ -33,7 +33,7 @@ func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionReq func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg bool - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/float64_function.go b/internal/framework5provider/float64_function.go index a51c5e7..adc7344 100644 --- a/internal/framework5provider/float64_function.go +++ b/internal/framework5provider/float64_function.go @@ -33,7 +33,7 @@ func (f Float64Function) Definition(ctx context.Context, req function.Definition func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg float64 - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/int64_function.go b/internal/framework5provider/int64_function.go index 3c9cfc2..5965766 100644 --- a/internal/framework5provider/int64_function.go +++ b/internal/framework5provider/int64_function.go @@ -33,7 +33,7 @@ func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRe func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg int64 - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/list_function.go b/internal/framework5provider/list_function.go index b0e7006..92bb092 100644 --- a/internal/framework5provider/list_function.go +++ b/internal/framework5provider/list_function.go @@ -38,7 +38,7 @@ func (f ListFunction) Definition(ctx context.Context, req function.DefinitionReq func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg []*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/map_function.go b/internal/framework5provider/map_function.go index 9cbce0b..4f32e69 100644 --- a/internal/framework5provider/map_function.go +++ b/internal/framework5provider/map_function.go @@ -38,7 +38,7 @@ func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequ func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg map[string]*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/number_function.go b/internal/framework5provider/number_function.go index 9faeacc..529eb78 100644 --- a/internal/framework5provider/number_function.go +++ b/internal/framework5provider/number_function.go @@ -34,7 +34,7 @@ func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionR func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg *big.Float - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/object_function.go b/internal/framework5provider/object_function.go index ca63ea8..73761e1 100644 --- a/internal/framework5provider/object_function.go +++ b/internal/framework5provider/object_function.go @@ -48,7 +48,7 @@ func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp * Attr2 *int64 `tfsdk:"attr2"` } - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/set_function.go b/internal/framework5provider/set_function.go index 453e5ca..9fc934a 100644 --- a/internal/framework5provider/set_function.go +++ b/internal/framework5provider/set_function.go @@ -38,7 +38,7 @@ func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequ func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg []*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/string_function.go b/internal/framework5provider/string_function.go index ea46dc6..5158f82 100644 --- a/internal/framework5provider/string_function.go +++ b/internal/framework5provider/string_function.go @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework5provider/variadic_function.go b/internal/framework5provider/variadic_function.go index 92f4b12..1a83a1c 100644 --- a/internal/framework5provider/variadic_function.go +++ b/internal/framework5provider/variadic_function.go @@ -34,7 +34,7 @@ func (f VariadicFunction) Definition(ctx context.Context, req function.Definitio func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var varg []string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...) + resp.Error = req.Arguments.Get(ctx, &varg) - resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, varg)) } diff --git a/internal/framework6provider/bool_function.go b/internal/framework6provider/bool_function.go index 352498f..844904e 100644 --- a/internal/framework6provider/bool_function.go +++ b/internal/framework6provider/bool_function.go @@ -33,7 +33,7 @@ func (f BoolFunction) Definition(ctx context.Context, req function.DefinitionReq func (f BoolFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg bool - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/float64_function.go b/internal/framework6provider/float64_function.go index a51c5e7..adc7344 100644 --- a/internal/framework6provider/float64_function.go +++ b/internal/framework6provider/float64_function.go @@ -33,7 +33,7 @@ func (f Float64Function) Definition(ctx context.Context, req function.Definition func (f Float64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg float64 - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/int64_function.go b/internal/framework6provider/int64_function.go index 3c9cfc2..5965766 100644 --- a/internal/framework6provider/int64_function.go +++ b/internal/framework6provider/int64_function.go @@ -33,7 +33,7 @@ func (f Int64Function) Definition(ctx context.Context, req function.DefinitionRe func (f Int64Function) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg int64 - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/list_function.go b/internal/framework6provider/list_function.go index b0e7006..92bb092 100644 --- a/internal/framework6provider/list_function.go +++ b/internal/framework6provider/list_function.go @@ -38,7 +38,7 @@ func (f ListFunction) Definition(ctx context.Context, req function.DefinitionReq func (f ListFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg []*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/map_function.go b/internal/framework6provider/map_function.go index 9cbce0b..4f32e69 100644 --- a/internal/framework6provider/map_function.go +++ b/internal/framework6provider/map_function.go @@ -38,7 +38,7 @@ func (f MapFunction) Definition(ctx context.Context, req function.DefinitionRequ func (f MapFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg map[string]*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/number_function.go b/internal/framework6provider/number_function.go index 9faeacc..529eb78 100644 --- a/internal/framework6provider/number_function.go +++ b/internal/framework6provider/number_function.go @@ -34,7 +34,7 @@ func (f NumberFunction) Definition(ctx context.Context, req function.DefinitionR func (f NumberFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg *big.Float - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/object_function.go b/internal/framework6provider/object_function.go index ca63ea8..73761e1 100644 --- a/internal/framework6provider/object_function.go +++ b/internal/framework6provider/object_function.go @@ -48,7 +48,7 @@ func (f ObjectFunction) Run(ctx context.Context, req function.RunRequest, resp * Attr2 *int64 `tfsdk:"attr2"` } - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/set_function.go b/internal/framework6provider/set_function.go index 453e5ca..9fc934a 100644 --- a/internal/framework6provider/set_function.go +++ b/internal/framework6provider/set_function.go @@ -38,7 +38,7 @@ func (f SetFunction) Definition(ctx context.Context, req function.DefinitionRequ func (f SetFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg []*string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/string_function.go b/internal/framework6provider/string_function.go index ea46dc6..5158f82 100644 --- a/internal/framework6provider/string_function.go +++ b/internal/framework6provider/string_function.go @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/framework6provider/variadic_function.go b/internal/framework6provider/variadic_function.go index 92f4b12..1a83a1c 100644 --- a/internal/framework6provider/variadic_function.go +++ b/internal/framework6provider/variadic_function.go @@ -34,7 +34,7 @@ func (f VariadicFunction) Definition(ctx context.Context, req function.Definitio func (f VariadicFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var varg []string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &varg)...) + resp.Error = req.Arguments.Get(ctx, &varg) - resp.Diagnostics.Append(resp.Result.Set(ctx, varg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, varg)) } diff --git a/internal/tf6muxprovider/provider1/function_string.go b/internal/tf6muxprovider/provider1/function_string.go index 0a1cca4..6f00e7e 100644 --- a/internal/tf6muxprovider/provider1/function_string.go +++ b/internal/tf6muxprovider/provider1/function_string.go @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/tf6muxprovider/provider2/function_string.go b/internal/tf6muxprovider/provider2/function_string.go index bdded42..66fecd0 100644 --- a/internal/tf6muxprovider/provider2/function_string.go +++ b/internal/tf6muxprovider/provider2/function_string.go @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } diff --git a/internal/tf6to5provider/provider/function_string.go b/internal/tf6to5provider/provider/function_string.go index 53b7be9..f446acf 100644 --- a/internal/tf6to5provider/provider/function_string.go +++ b/internal/tf6to5provider/provider/function_string.go @@ -33,7 +33,7 @@ func (f StringFunction) Definition(ctx context.Context, req function.DefinitionR func (f StringFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { var arg string - resp.Diagnostics.Append(req.Arguments.Get(ctx, &arg)...) + resp.Error = req.Arguments.Get(ctx, &arg) - resp.Diagnostics.Append(resp.Result.Set(ctx, arg)...) + resp.Error = function.ConcatFuncErrors(resp.Error, resp.Result.Set(ctx, arg)) } From 8c75971db745adeab6b8051cdc4941863c38451a Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Wed, 6 Mar 2024 16:08:45 +0000 Subject: [PATCH 12/12] Updates following code review (#202) --- .../float64_precision_resource_test.go | 4 --- internal/framework5provider/provider.go | 4 +++ .../framework5provider/resource_user_test.go | 5 --- .../schema_resource_test.go | 25 -------------- .../timeouts_resource_test.go | 2 -- .../float64_precision_resource_test.go | 4 --- .../number_function_test.go | 9 +---- .../framework6provider/resource_user_test.go | 5 --- .../schema_resource_test.go | 33 ------------------- .../timeouts_resource_test.go | 2 -- internal/protocolprovider/data_time_test.go | 1 - internal/protocolv6provider/data_time_test.go | 1 - .../sdkv2provider/data_source_bigint_test.go | 1 - .../data_source_regions_cty_test.go | 1 - .../sdkv2provider/data_source_regions_test.go | 1 - .../sdkv2provider/resource_bigint_test.go | 1 - .../sdkv2provider/resource_user_cty_test.go | 2 -- internal/sdkv2provider/resource_user_test.go | 1 - .../data_source_bigint_test.go | 1 - .../data_source_regions_cty_test.go | 1 - .../data_source_regions_test.go | 1 - .../resource_bigint_test.go | 1 - .../resource_user_cty_test.go | 2 -- .../resource_user_test.go | 1 - .../provider1/resource_user_test.go | 1 - .../provider2/resource_user_test.go | 1 - internal/tf5muxprovider/provider_test.go | 1 - .../provider/resource_user_test.go | 1 - internal/tf5to6provider/provider_test.go | 1 - .../provider1/resource_user_test.go | 1 - .../provider2/resource_user_test.go | 1 - internal/tf6muxprovider/provider_test.go | 1 - .../provider/resource_user_test.go | 1 - internal/tf6to5provider/provider_test.go | 1 - 34 files changed, 5 insertions(+), 114 deletions(-) diff --git a/internal/framework5provider/float64_precision_resource_test.go b/internal/framework5provider/float64_precision_resource_test.go index a9ae29f..7e83d81 100644 --- a/internal/framework5provider/float64_precision_resource_test.go +++ b/internal/framework5provider/float64_precision_resource_test.go @@ -24,7 +24,6 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.99 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), @@ -33,7 +32,6 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.98 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006"), ), @@ -54,7 +52,6 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 0.01 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.01"), ), @@ -68,7 +65,6 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { plancheck.ExpectNonEmptyPlan(), }, }, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), diff --git a/internal/framework5provider/provider.go b/internal/framework5provider/provider.go index 30637fa..493467f 100644 --- a/internal/framework5provider/provider.go +++ b/internal/framework5provider/provider.go @@ -15,6 +15,10 @@ import ( "github.com/hashicorp/terraform-provider-corner/internal/backend" ) +var ( + _ provider.ProviderWithFunctions = (*testProvider)(nil) +) + func New() provider.Provider { return &testProvider{} } diff --git a/internal/framework5provider/resource_user_test.go b/internal/framework5provider/resource_user_test.go index dae2826..d5dfe95 100644 --- a/internal/framework5provider/resource_user_test.go +++ b/internal/framework5provider/resource_user_test.go @@ -19,7 +19,6 @@ func TestAccFrameworkResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -45,7 +44,6 @@ func TestAccFrameworkResourceUser_language(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserLanguage, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "J Doe"), @@ -76,7 +74,6 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -92,7 +89,6 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { }, { Config: configResourceUserLanguageInterpolated, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -134,7 +130,6 @@ resource "framework_user" "test" { id = "h" } `, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_user.test", "name", expectedUserName), ), diff --git a/internal/framework5provider/schema_resource_test.go b/internal/framework5provider/schema_resource_test.go index 3a7fe11..2f22778 100644 --- a/internal/framework5provider/schema_resource_test.go +++ b/internal/framework5provider/schema_resource_test.go @@ -19,7 +19,6 @@ func TestSchemaResource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_schema" "test" {}`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -50,7 +49,6 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = true }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "true"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -71,7 +69,6 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = false }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "false"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -102,7 +99,6 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 1234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "1234.5"), @@ -123,7 +119,6 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 2234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "2234.5"), @@ -154,7 +149,6 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 1234 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -175,7 +169,6 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 2345 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -206,7 +199,6 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value1"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -228,7 +220,6 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value2"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -262,7 +253,6 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -286,7 +276,6 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -320,7 +309,6 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -344,7 +332,6 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -376,7 +363,6 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 1234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -397,7 +383,6 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 2234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -430,7 +415,6 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -453,7 +437,6 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -484,7 +467,6 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value1"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -506,7 +488,6 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value2"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -540,7 +521,6 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -566,7 +546,6 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -602,7 +581,6 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -625,7 +603,6 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -656,7 +633,6 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value1" }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -677,7 +653,6 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value2" }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), diff --git a/internal/framework5provider/timeouts_resource_test.go b/internal/framework5provider/timeouts_resource_test.go index c067ed9..05d4e76 100644 --- a/internal/framework5provider/timeouts_resource_test.go +++ b/internal/framework5provider/timeouts_resource_test.go @@ -19,7 +19,6 @@ func TestTimeoutsResource_unconfigured(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_timeouts" "test" {}`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckNoResourceAttr("framework_timeouts.test", "timeouts"), @@ -41,7 +40,6 @@ func TestTimeoutsResource_configured(t *testing.T) { create = "120s" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckResourceAttr("framework_timeouts.test", "timeouts.create", "120s"), diff --git a/internal/framework6provider/float64_precision_resource_test.go b/internal/framework6provider/float64_precision_resource_test.go index 6deccaa..ea92b8d 100644 --- a/internal/framework6provider/float64_precision_resource_test.go +++ b/internal/framework6provider/float64_precision_resource_test.go @@ -24,7 +24,6 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.99 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), @@ -33,7 +32,6 @@ func TestSchemaResource_Float64Attribute_Precision(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 1 - 0.98 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006"), ), @@ -54,7 +52,6 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { Config: `resource "framework_float64_precision" "test" { float64_attribute = 0.01 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.01"), ), @@ -68,7 +65,6 @@ func TestSchemaResource_Float64Attribute_Precision_Plan(t *testing.T) { plancheck.ExpectNonEmptyPlan(), }, }, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_float64_precision.test", "float64_attribute", "0.010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003"), ), diff --git a/internal/framework6provider/number_function_test.go b/internal/framework6provider/number_function_test.go index 0b72379..73ebc71 100644 --- a/internal/framework6provider/number_function_test.go +++ b/internal/framework6provider/number_function_test.go @@ -19,14 +19,7 @@ import ( ) func TestNumberFunction_known(t *testing.T) { - // Using 9223372036854775808, the smallest number that can't be represented as an int64, - // results in an Terraform error where [Planned value does not match config value for cty.NumberIntVal], - // which is related to a bug in go.cty relating to [Large integer comparisons and msgpack encoding]. - // A value of 9223372036854775809 is used for the meanwhile. - // - // [Planned value does not match config value for cty.NumberIntVal]: https://github.com/hashicorp/terraform/issues/34589 - // [Large integer comparisons and msgpack encoding]: https://github.com/zclconf/go-cty/pull/176 - bf, _, err := big.ParseFloat("9223372036854775809", 10, 512, big.ToNearestEven) + bf, _, err := big.ParseFloat("9223372036854775808", 10, 512, big.ToNearestEven) if err != nil { t.Errorf("%s", err) diff --git a/internal/framework6provider/resource_user_test.go b/internal/framework6provider/resource_user_test.go index 329428f..352c91f 100644 --- a/internal/framework6provider/resource_user_test.go +++ b/internal/framework6provider/resource_user_test.go @@ -19,7 +19,6 @@ func TestAccFrameworkResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -45,7 +44,6 @@ func TestAccFrameworkResourceUser_language(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserLanguage, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "J Doe"), @@ -76,7 +74,6 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -92,7 +89,6 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) { }, { Config: configResourceUserLanguageInterpolated, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "framework_user.foo", "name", "Ford Prefect"), @@ -134,7 +130,6 @@ resource "framework_user" "test" { id = "h" } `, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_user.test", "name", expectedUserName), ), diff --git a/internal/framework6provider/schema_resource_test.go b/internal/framework6provider/schema_resource_test.go index 5ab2ef0..1245246 100644 --- a/internal/framework6provider/schema_resource_test.go +++ b/internal/framework6provider/schema_resource_test.go @@ -19,7 +19,6 @@ func TestSchemaResource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_schema" "test" {}`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -54,7 +53,6 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = true }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "true"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -79,7 +77,6 @@ func TestSchemaResource_BoolAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { bool_attribute = false }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_schema.test", "bool_attribute", "false"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -114,7 +111,6 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 1234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "1234.5"), @@ -139,7 +135,6 @@ func TestSchemaResource_Float64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { float64_attribute = 2234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckResourceAttr("framework_schema.test", "float64_attribute", "2234.5"), @@ -174,7 +169,6 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 1234 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -199,7 +193,6 @@ func TestSchemaResource_Int64Attribute(t *testing.T) { Config: `resource "framework_schema" "test" { int64_attribute = 2345 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -234,7 +227,6 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value1"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -260,7 +252,6 @@ func TestSchemaResource_ListAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { list_attribute = ["value2"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -300,7 +291,6 @@ func TestSchemaResource_ListNestedAttribute(t *testing.T) { }, ] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -330,7 +320,6 @@ func TestSchemaResource_ListNestedAttribute(t *testing.T) { }, ] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -368,7 +357,6 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -396,7 +384,6 @@ func TestSchemaResource_ListNestedBlock(t *testing.T) { list_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -434,7 +421,6 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -462,7 +448,6 @@ func TestSchemaResource_MapAttribute(t *testing.T) { key1 = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -502,7 +487,6 @@ func TestSchemaResource_MapNestedAttribute(t *testing.T) { }, } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -532,7 +516,6 @@ func TestSchemaResource_MapNestedAttribute(t *testing.T) { }, } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -568,7 +551,6 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 1234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -593,7 +575,6 @@ func TestSchemaResource_NumberAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { number_attribute = 2234.5 }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -630,7 +611,6 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -657,7 +637,6 @@ func TestSchemaResource_ObjectAttribute(t *testing.T) { object_attribute_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -692,7 +671,6 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value1"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -718,7 +696,6 @@ func TestSchemaResource_SetAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { set_attribute = ["value2"] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -758,7 +735,6 @@ func TestSchemaResource_SetNestedAttribute(t *testing.T) { }, ] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -790,7 +766,6 @@ func TestSchemaResource_SetNestedAttribute(t *testing.T) { }, ] }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -830,7 +805,6 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -860,7 +834,6 @@ func TestSchemaResource_SetNestedBlock(t *testing.T) { set_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -900,7 +873,6 @@ func TestSchemaResource_SingleNestedAttribute(t *testing.T) { single_nested_attribute_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -927,7 +899,6 @@ func TestSchemaResource_SingleNestedAttribute(t *testing.T) { single_nested_attribute_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -964,7 +935,6 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value1" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -991,7 +961,6 @@ func TestSchemaResource_SingleNestedBlock(t *testing.T) { single_nested_block_attribute = "value2" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -1026,7 +995,6 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value1" }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), @@ -1051,7 +1019,6 @@ func TestSchemaResource_StringAttribute(t *testing.T) { Config: `resource "framework_schema" "test" { string_attribute = "value2" }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckNoResourceAttr("framework_schema.test", "bool_attribute"), resource.TestCheckNoResourceAttr("framework_schema.test", "float64_attribute"), diff --git a/internal/framework6provider/timeouts_resource_test.go b/internal/framework6provider/timeouts_resource_test.go index 8857b20..0f17d25 100644 --- a/internal/framework6provider/timeouts_resource_test.go +++ b/internal/framework6provider/timeouts_resource_test.go @@ -19,7 +19,6 @@ func TestTimeoutsResource_unconfigured(t *testing.T) { Steps: []resource.TestStep{ { Config: `resource "framework_timeouts" "test" {}`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckNoResourceAttr("framework_timeouts.test", "timeouts"), @@ -41,7 +40,6 @@ func TestTimeoutsResource_configured(t *testing.T) { create = "120s" } }`, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("framework_timeouts.test", "id", "test"), resource.TestCheckResourceAttr("framework_timeouts.test", "timeouts.create", "120s"), diff --git a/internal/protocolprovider/data_time_test.go b/internal/protocolprovider/data_time_test.go index 949a9ed..841e41d 100644 --- a/internal/protocolprovider/data_time_test.go +++ b/internal/protocolprovider/data_time_test.go @@ -22,7 +22,6 @@ func TestAccDataSourceTime(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDataSourceTimeConfig, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("data.corner_time.foo", "current", regexp.MustCompile(`[0-9]+`)), ), diff --git a/internal/protocolv6provider/data_time_test.go b/internal/protocolv6provider/data_time_test.go index c93422d..33e0e1b 100644 --- a/internal/protocolv6provider/data_time_test.go +++ b/internal/protocolv6provider/data_time_test.go @@ -22,7 +22,6 @@ func TestAccV6DataSourceTime(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccDataSourceTimeConfig, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("data.corner_v6_time.foo", "current", regexp.MustCompile(`[0-9]+`)), ), diff --git a/internal/sdkv2provider/data_source_bigint_test.go b/internal/sdkv2provider/data_source_bigint_test.go index 89e68ff..f9bf15e 100644 --- a/internal/sdkv2provider/data_source_bigint_test.go +++ b/internal/sdkv2provider/data_source_bigint_test.go @@ -16,7 +16,6 @@ func testAccDataSourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBigint, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.corner_bigint.foo", "int64", "7227701560655103598")), }, diff --git a/internal/sdkv2provider/data_source_regions_cty_test.go b/internal/sdkv2provider/data_source_regions_cty_test.go index 463dec5..b987f09 100644 --- a/internal/sdkv2provider/data_source_regions_cty_test.go +++ b/internal/sdkv2provider/data_source_regions_cty_test.go @@ -16,7 +16,6 @@ func testAccDataSourceRegionsCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceRegionsCtyBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions_cty.foo", "names.#")), }, diff --git a/internal/sdkv2provider/data_source_regions_test.go b/internal/sdkv2provider/data_source_regions_test.go index 260ef30..e094f5b 100644 --- a/internal/sdkv2provider/data_source_regions_test.go +++ b/internal/sdkv2provider/data_source_regions_test.go @@ -16,7 +16,6 @@ func testAccDataSourceRegions(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions.foo", "names.#")), }, diff --git a/internal/sdkv2provider/resource_bigint_test.go b/internal/sdkv2provider/resource_bigint_test.go index a2a8e33..041f0ea 100644 --- a/internal/sdkv2provider/resource_bigint_test.go +++ b/internal/sdkv2provider/resource_bigint_test.go @@ -16,7 +16,6 @@ func testAccResourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBigint, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("corner_bigint.foo", "number", "7227701560655103598"), resource.TestCheckResourceAttr("corner_bigint.foo", "int64", "7227701560655103598"), diff --git a/internal/sdkv2provider/resource_user_cty_test.go b/internal/sdkv2provider/resource_user_cty_test.go index c80dc35..a5b74c5 100644 --- a/internal/sdkv2provider/resource_user_cty_test.go +++ b/internal/sdkv2provider/resource_user_cty_test.go @@ -16,7 +16,6 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceUserCtyBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), @@ -28,7 +27,6 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { }, { Config: configResourceUserCtyUpdate, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), diff --git a/internal/sdkv2provider/resource_user_test.go b/internal/sdkv2provider/resource_user_test.go index 8fb4737..a068358 100644 --- a/internal/sdkv2provider/resource_user_test.go +++ b/internal/sdkv2provider/resource_user_test.go @@ -17,7 +17,6 @@ func testAccResourceUser(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr( "corner_user.foo", "name", regexp.MustCompile("^For")), diff --git a/internal/sdkv2testingprovider/data_source_bigint_test.go b/internal/sdkv2testingprovider/data_source_bigint_test.go index 9cc336f..63a40d0 100644 --- a/internal/sdkv2testingprovider/data_source_bigint_test.go +++ b/internal/sdkv2testingprovider/data_source_bigint_test.go @@ -16,7 +16,6 @@ func testAccDataSourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBigint, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.corner_bigint.foo", "int64", "7227701560655103598")), }, diff --git a/internal/sdkv2testingprovider/data_source_regions_cty_test.go b/internal/sdkv2testingprovider/data_source_regions_cty_test.go index 6350a48..7b0df7d 100644 --- a/internal/sdkv2testingprovider/data_source_regions_cty_test.go +++ b/internal/sdkv2testingprovider/data_source_regions_cty_test.go @@ -16,7 +16,6 @@ func testAccDataSourceRegionsCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceRegionsCtyBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions_cty.foo", "names.#")), }, diff --git a/internal/sdkv2testingprovider/data_source_regions_test.go b/internal/sdkv2testingprovider/data_source_regions_test.go index d2278c7..39081d9 100644 --- a/internal/sdkv2testingprovider/data_source_regions_test.go +++ b/internal/sdkv2testingprovider/data_source_regions_test.go @@ -16,7 +16,6 @@ func testAccDataSourceRegions(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configDataSourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.corner_regions.foo", "names.#")), }, diff --git a/internal/sdkv2testingprovider/resource_bigint_test.go b/internal/sdkv2testingprovider/resource_bigint_test.go index f6e8361..4eafb16 100644 --- a/internal/sdkv2testingprovider/resource_bigint_test.go +++ b/internal/sdkv2testingprovider/resource_bigint_test.go @@ -16,7 +16,6 @@ func testAccResourceBigint(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBigint, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("corner_bigint.foo", "number", "7227701560655103598"), resource.TestCheckResourceAttr("corner_bigint.foo", "int64", "7227701560655103598"), diff --git a/internal/sdkv2testingprovider/resource_user_cty_test.go b/internal/sdkv2testingprovider/resource_user_cty_test.go index bfe066e..f92a73b 100644 --- a/internal/sdkv2testingprovider/resource_user_cty_test.go +++ b/internal/sdkv2testingprovider/resource_user_cty_test.go @@ -16,7 +16,6 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceUserCtyBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), @@ -28,7 +27,6 @@ func testAccResourceUserCty(t *testing.T) resource.TestCase { }, { Config: configResourceUserCtyUpdate, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "corner_user.foo", "email", "ford@prefect.co"), diff --git a/internal/sdkv2testingprovider/resource_user_test.go b/internal/sdkv2testingprovider/resource_user_test.go index 87e21e2..34c73e0 100644 --- a/internal/sdkv2testingprovider/resource_user_test.go +++ b/internal/sdkv2testingprovider/resource_user_test.go @@ -17,7 +17,6 @@ func testAccResourceUser(t *testing.T) resource.TestCase { Steps: []resource.TestStep{ { Config: configResourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr( "corner_user.foo", "name", regexp.MustCompile("^For")), diff --git a/internal/tf5muxprovider/provider1/resource_user_test.go b/internal/tf5muxprovider/provider1/resource_user_test.go index a26a708..647cac1 100644 --- a/internal/tf5muxprovider/provider1/resource_user_test.go +++ b/internal/tf5muxprovider/provider1/resource_user_test.go @@ -16,7 +16,6 @@ func TestAccResourceUser1(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5muxprovider_user1.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5muxprovider/provider2/resource_user_test.go b/internal/tf5muxprovider/provider2/resource_user_test.go index ef2ca8a..2d91044 100644 --- a/internal/tf5muxprovider/provider2/resource_user_test.go +++ b/internal/tf5muxprovider/provider2/resource_user_test.go @@ -16,7 +16,6 @@ func TestAccResourceUser2(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5muxprovider_user2.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5muxprovider/provider_test.go b/internal/tf5muxprovider/provider_test.go index fcac80d..ef2b5dc 100644 --- a/internal/tf5muxprovider/provider_test.go +++ b/internal/tf5muxprovider/provider_test.go @@ -22,7 +22,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf5muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf5muxprovider_user1.example", "email", "example1@example.com"), diff --git a/internal/tf5to6provider/provider/resource_user_test.go b/internal/tf5to6provider/provider/resource_user_test.go index 297ecfb..f3e98d1 100644 --- a/internal/tf5to6provider/provider/resource_user_test.go +++ b/internal/tf5to6provider/provider/resource_user_test.go @@ -16,7 +16,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestMatchResourceAttr("tf5to6provider_user.example", "name", regexp.MustCompile("^Exam")), ), diff --git a/internal/tf5to6provider/provider_test.go b/internal/tf5to6provider/provider_test.go index df9c8e3..1f0f708 100644 --- a/internal/tf5to6provider/provider_test.go +++ b/internal/tf5to6provider/provider_test.go @@ -22,7 +22,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf5to6provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf5to6provider_user.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider1/resource_user_test.go b/internal/tf6muxprovider/provider1/resource_user_test.go index c06bf7d..97bf105 100644 --- a/internal/tf6muxprovider/provider1/resource_user_test.go +++ b/internal/tf6muxprovider/provider1/resource_user_test.go @@ -19,7 +19,6 @@ func TestAccResourceUser1(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider2/resource_user_test.go b/internal/tf6muxprovider/provider2/resource_user_test.go index 21cdf78..196a05a 100644 --- a/internal/tf6muxprovider/provider2/resource_user_test.go +++ b/internal/tf6muxprovider/provider2/resource_user_test.go @@ -19,7 +19,6 @@ func TestAccResourceUser2(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user2.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user2.example", "email", "example@example.com"), diff --git a/internal/tf6muxprovider/provider_test.go b/internal/tf6muxprovider/provider_test.go index 3c866be..f668a48 100644 --- a/internal/tf6muxprovider/provider_test.go +++ b/internal/tf6muxprovider/provider_test.go @@ -25,7 +25,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "age", "123"), resource.TestCheckResourceAttr("tf6muxprovider_user1.example", "email", "example1@example.com"), diff --git a/internal/tf6to5provider/provider/resource_user_test.go b/internal/tf6to5provider/provider/resource_user_test.go index 19c3fad..026ee77 100644 --- a/internal/tf6to5provider/provider/resource_user_test.go +++ b/internal/tf6to5provider/provider/resource_user_test.go @@ -19,7 +19,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6to5provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf6to5provider_user.example", "email", "example@example.com"), diff --git a/internal/tf6to5provider/provider_test.go b/internal/tf6to5provider/provider_test.go index c98770f..00f753b 100644 --- a/internal/tf6to5provider/provider_test.go +++ b/internal/tf6to5provider/provider_test.go @@ -25,7 +25,6 @@ func TestAccResourceUser(t *testing.T) { Steps: []resource.TestStep{ { Config: configResourceUserBasic, - //nolint:staticcheck //Deprecated functions Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("tf6to5provider_user.example", "age", "123"), resource.TestCheckResourceAttr("tf6to5provider_user.example", "email", "example@example.com"),