Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnester committed Sep 30, 2024
1 parent 7d2d522 commit 398c4c8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bundle/deploy/terraform/state_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package terraform
import (
"context"
"encoding/json"
"fmt"
"io"
"testing"

Expand Down Expand Up @@ -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")
}

0 comments on commit 398c4c8

Please sign in to comment.