added test

This commit is contained in:
Andrew Nester 2024-09-30 13:13:02 +02:00
parent 7d2d522497
commit 398c4c8df5
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
1 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package terraform
import (
"context"
"encoding/json"
"fmt"
"io"
"testing"
@ -59,3 +60,23 @@ func TestStatePush(t *testing.T) {
diags := bundle.Apply(ctx, b, m)
assert.NoError(t, diags.Error())
}
func TestStatePushLargeState(t *testing.T) {
mock := mockfiler.NewMockFiler(t)
m := &statePush{
identityFiler(mock),
}
ctx := context.Background()
b := statePushTestBundle(t)
largeState := map[string]any{}
for i := 0; i < 1000000; i++ {
largeState[fmt.Sprintf("field_%d", i)] = i
}
// Write a stale local state file.
writeLocalState(t, ctx, b, largeState)
diags := bundle.Apply(ctx, b, m)
assert.ErrorContains(t, diags.Error(), "Terraform state file size exceeds the maximum allowed size of 10485760 bytes. Please reduce the number of resources in your bundle, split your bundle into multiple or re-run the command with --force flag")
}