Using terraform test on templatefile content

I am using terraform test to test plans however having trouble understanding why I cannot make assertions about the content of a templatefile.

The code under test is:

locals {
  user_data_rendered = templatefile("${path.module}/userdata.tpl", {
    AutomationAssumeRole = aws_iam_role.main.arn
  })

User data template (userdata.tpl):

${AutomationAssumeRole}

Data mock:

  mock_data "aws_iam_role" {
    defaults = {
      name = "fake-role"
      arn  = "arn:aws:iam::123456789012:role/fake-role"
    }
  }

Test case:

run "validate_user_data_rendered" {
  command = plan
    
  assert {
    condition = local.user_data_rendered == "arn:aws:iam::123456789012:role/fake-role\n"
      
    error_message = "Expected the full user_data_rendered content to match."
  }
}

On running terraform test:

│ Error: Unknown condition value
│·
│   on tests/test_instances.tftest.hcl line 196, in run "validate_user_data_rendered":
│  196:     condition = local.user_data_rendered == "arn:aws:iam::123456789012:role/fake-role\n"
│     ├────────────────
│     │ local.user_data_rendered is a string
│·
│ Condition expression could not be evaluated at this time. This means you have executed a `run` block with `command = plan` and one of the values your condition depended on is not known until
│ after the plan has been applied. Either remove this value from your condition, or execute an `apply` command from this `run` block.

This sort of makes sense as normally the value of the ARN will not be known until after apply (although since I have mocked the ARN, we actually know it beforehand in the test).

Is there any workaround that allows me to test this templatefile generation or do I have to use command = apply?

We will add support for mocking data during the plan operation in the upcoming v1.11.0 release: terraform test: allow computed/mocked values override during planning by dsa0x · Pull Request #36227 · hashicorp/terraform · GitHub.

For now, you must use command = apply for any tests that rely directly on mocked data.