Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/unit/test_platforms.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some thoughts:

  1. Platform names are used for the container name. Craft-providers sanitizes platform names before creating a container, so this isn't a concern.
  2. Platform names are used in the resulting artifact. So it may be prudent to only allow characters allowed in file paths. We could add a few extra characters and replace them. I think we are already doing this with @ or : symbols in Charmcraft.
  3. For usability, we could set a maximum limit. The artifact filename should be less than 255 characters (a common max), so this could drive the maximum limit.
  4. We could set a reasonable ruleset. Unless there is a real need to support the platform names in this PR, I'd be fine for something along the lines of:

Can contain alphanumerics, :, @, - and _, must start and end with an alphanumeric, max length is 64 characters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want 🇿🇦 to be a valid platform name.

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,34 @@
)
for arch in craft_platforms.DebianArchitecture
),
pytest.param(
{
"🐉🎄 Ⓣ卄I𝐬 ⓘ𝕊 α ש𝓐𝐋𝐢𝓓 ρlάţƑᵒᖇ𝔪 ᑎคⓜⒺ 👣♡": { # noqa: RUF001
"build-on": ["amd64"],
"build-for": ["all"],
}
},
{
"🐉🎄 Ⓣ卄I𝐬 ⓘ𝕊 α ש𝓐𝐋𝐢𝓓 ρlάţƑᵒᖇ𝔪 ᑎคⓜⒺ 👣♡": [ # noqa: RUF001
(craft_platforms.DebianArchitecture.AMD64, "all"),
],
},
id="crazy-text",
),
pytest.param(
{
"ǝɯɐu ɯɹoɟʇɐld pılɐʌ ɐ sı sıɥ⊥": { # noqa: RUF001
"build-on": ["amd64"],
"build-for": ["all"],
}
},
{
"ǝɯɐu ɯɹoɟʇɐld pılɐʌ ɐ sı sıɥ⊥": [ # noqa: RUF001
(craft_platforms.DebianArchitecture.AMD64, "all"),
],
},
id="southern-hemisphere-validity",
),
],
)
def test_build_plans_success(
Expand Down