diff --git a/spinifex/utils/utils.go b/spinifex/utils/utils.go index 0120d06fc..e2edd2511 100644 --- a/spinifex/utils/utils.go +++ b/spinifex/utils/utils.go @@ -137,17 +137,6 @@ func UnmarshalJsonPayload(input any, jsonData []byte) []byte { return nil } -func MarshalJsonPayload(input any, jsonData []byte) []byte { - decoder := json.NewDecoder(bytes.NewReader(jsonData)) - decoder.DisallowUnknownFields() - err := decoder.Decode(input) - if err != nil { - return GenerateErrorPayload(awserrors.ErrorValidationError) - } - - return nil -} - // ValidateKeyPairName validates that a key pair name contains only [A-Za-z0-9._-]. // Rejects empty names and returns ErrorInvalidKeyPairFormat on any invalid character. func ValidateKeyPairName(name string) error { diff --git a/spinifex/utils/utils_test.go b/spinifex/utils/utils_test.go index 851368024..b2e38ba83 100644 --- a/spinifex/utils/utils_test.go +++ b/spinifex/utils/utils_test.go @@ -325,52 +325,6 @@ func TestUnmarshalJsonPayload(t *testing.T) { } } -func TestMarshalJsonPayload(t *testing.T) { - type TestStruct struct { - Name string `json:"name"` - Value int `json:"value"` - } - - tests := []struct { - name string - jsonData string - expectError bool - validate func(t *testing.T, result *TestStruct) - }{ - { - name: "Valid JSON", - jsonData: `{"name":"test","value":456}`, - expectError: false, - validate: func(t *testing.T, result *TestStruct) { - assert.Equal(t, "test", result.Name) - assert.Equal(t, 456, result.Value) - }, - }, - { - name: "Invalid JSON", - jsonData: `{"name":"test","value":}`, - expectError: true, - validate: nil, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var result TestStruct - errResp := MarshalJsonPayload(&result, []byte(tt.jsonData)) - - if tt.expectError { - assert.NotNil(t, errResp, "Expected error response") - } else { - assert.Nil(t, errResp, "Expected no error response") - if tt.validate != nil { - tt.validate(t, &result) - } - } - }) - } -} - func TestGenerateErrorPayload(t *testing.T) { tests := []struct { name string