Skip to content

feat: Tests for product module channel input#185

Open
MichaelThamm wants to merge 10 commits intotrack/2from
feat/channel-tf-tests
Open

feat: Tests for product module channel input#185
MichaelThamm wants to merge 10 commits intotrack/2from
feat/channel-tf-tests

Conversation

@MichaelThamm
Copy link
Contributor

@MichaelThamm MichaelThamm commented Feb 10, 2026

  • Merge this into main as well

Issue

If a user specifies the TF COS (or COS Lite) modules

  1. without a ref "git::.../observability-stack//terraform/cos-lite then they must use track dev
  2. with a ref "git::.../observability-stack//terraform/cos-lite?ref=track/2 then they must use track 2

I noticed some users make this mistake (and I) where you try out a different track, e.g. dev, but leave the module source as ?ref=track/2 and notice a failure to deploy.

Solution

module "cos-lite" {
  source                          = "../../cos-lite"
  model_uuid                      = juju_model.cos-lite.uuid
  channel                         = "3/stable"
}
│ Error: Invalid value for variable
│ 
│   on root.tf line 19, in module "cos-lite":
│   19:   channel                         = "3/stable"
│     ├────────────────
│     │ var.channel is "3/stable"
│ 
│ The track of the channel must be '2/'. e.g. '2/stable'.
│ 
│ This was checked by the validation rule at ../../cos-lite/variables.tf:18,3-13.

Checklist

  • I have added or updated relevant documentation.
  • PR title makes an appropriate release note and follows conventional commits syntax.
  • Merge target is the correct branch, and relevant tandem backport PRs opened.

Context

Testing Instructions

Running Terraform tests:

  • tf -chdir=terraform/cos test
  • tf -chdir=terraform/cos-lite test

will result in running unit tests for channel validation

tests/channel_validation.tftest.hcl... in progress
  run "valid_channel_track"... pass
  run "valid_channel_stable"... pass
  run "valid_channel_candidate"... pass
  run "valid_channel_beta"... pass
  run "invalid_channel_track"... pass
  run "invalid_channel_track_numeric"... pass
  run "invalid_channel_track_string"... pass
  run "invalid_channel_track_dev"... pass
tests/channel_validation.tftest.hcl... tearing down
tests/channel_validation.tftest.hcl... pass

Success! 8 passed, 0 failed.

Upgrade Notes

@MichaelThamm MichaelThamm marked this pull request as ready for review March 9, 2026 13:07
Copy link
Contributor

@sed-i sed-i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants