@@ -688,121 +688,6 @@ func TestApplyResourceChange(t *testing.T) {
688688 }
689689}
690690
691- func TestApplyResourceChange_bigint (t * testing.T ) {
692- testCases := []struct {
693- Description string
694- TestResource * Resource
695- }{
696- {
697- Description : "Create" ,
698- TestResource : & Resource {
699- UseJSONNumber : true ,
700- Schema : map [string ]* Schema {
701- "foo" : {
702- Type : TypeInt ,
703- Required : true ,
704- },
705- },
706- Create : func (rd * ResourceData , _ interface {}) error {
707- rd .SetId ("bar" )
708- return nil
709- },
710- },
711- },
712- {
713- Description : "CreateContext" ,
714- TestResource : & Resource {
715- UseJSONNumber : true ,
716- Schema : map [string ]* Schema {
717- "foo" : {
718- Type : TypeInt ,
719- Required : true ,
720- },
721- },
722- CreateContext : func (_ context.Context , rd * ResourceData , _ interface {}) diag.Diagnostics {
723- rd .SetId ("bar" )
724- return nil
725- },
726- },
727- },
728- {
729- Description : "CreateWithoutTimeout" ,
730- TestResource : & Resource {
731- UseJSONNumber : true ,
732- Schema : map [string ]* Schema {
733- "foo" : {
734- Type : TypeInt ,
735- Required : true ,
736- },
737- },
738- CreateWithoutTimeout : func (_ context.Context , rd * ResourceData , _ interface {}) diag.Diagnostics {
739- rd .SetId ("bar" )
740- return nil
741- },
742- },
743- },
744- }
745-
746- for _ , testCase := range testCases {
747- testCase := testCase
748- t .Run (testCase .Description , func (t * testing.T ) {
749- server := NewGRPCProviderServer (& Provider {
750- ResourcesMap : map [string ]* Resource {
751- "test" : testCase .TestResource ,
752- },
753- })
754-
755- schema := testCase .TestResource .CoreConfigSchema ()
756- priorState , err := msgpack .Marshal (cty .NullVal (schema .ImpliedType ()), schema .ImpliedType ())
757- if err != nil {
758- t .Fatal (err )
759- }
760-
761- plannedVal := cty .ObjectVal (map [string ]cty.Value {
762- "id" : cty .UnknownVal (cty .String ),
763- "foo" : cty .MustParseNumberVal ("7227701560655103598" ),
764- })
765- plannedState , err := msgpack .Marshal (plannedVal , schema .ImpliedType ())
766- if err != nil {
767- t .Fatal (err )
768- }
769-
770- testReq := & tfprotov5.ApplyResourceChangeRequest {
771- TypeName : "test" ,
772- PriorState : & tfprotov5.DynamicValue {
773- MsgPack : priorState ,
774- },
775- PlannedState : & tfprotov5.DynamicValue {
776- MsgPack : plannedState ,
777- },
778- }
779-
780- resp , err := server .ApplyResourceChange (context .Background (), testReq )
781- if err != nil {
782- t .Fatal (err )
783- }
784-
785- newStateVal , err := msgpack .Unmarshal (resp .NewState .MsgPack , schema .ImpliedType ())
786- if err != nil {
787- t .Fatal (err )
788- }
789-
790- id := newStateVal .GetAttr ("id" ).AsString ()
791- if id != "bar" {
792- t .Fatalf ("incorrect final state: %#v\n " , newStateVal )
793- }
794-
795- foo , acc := newStateVal .GetAttr ("foo" ).AsBigFloat ().Int64 ()
796- if acc != big .Exact {
797- t .Fatalf ("Expected exact accuracy, got %s" , acc )
798- }
799- if foo != 7227701560655103598 {
800- t .Fatalf ("Expected %d, got %d, this represents a loss of precision in applying large numbers" , 7227701560655103598 , foo )
801- }
802- })
803- }
804- }
805-
806691func TestPrepareProviderConfig (t * testing.T ) {
807692 for _ , tc := range []struct {
808693 Name string
0 commit comments