-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use valid GCP resource names (#1248)
- Loading branch information
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
from dstack._internal.core.backends.gcp import resources as gcp_resources | ||
|
||
|
||
class TestIsValidResourceName: | ||
@pytest.mark.parametrize( | ||
"name", | ||
[ | ||
"", | ||
"1", | ||
"a" * 64, | ||
"-startswithdash", | ||
"1startswithdigit", | ||
"asd_asd", | ||
"Uppercase", | ||
], | ||
) | ||
def test_invalid_name(self, name): | ||
assert not gcp_resources.is_valid_resource_name(name) | ||
|
||
@pytest.mark.parametrize("name", ["a", "some-name-with-dashes-123"]) | ||
def test_valid_name(self, name): | ||
assert gcp_resources.is_valid_resource_name(name) | ||
|
||
|
||
class TestIsValidLabelValue: | ||
@pytest.mark.parametrize( | ||
"name", | ||
[ | ||
"a" * 64, | ||
"asd_asd", | ||
"Uppercase", | ||
], | ||
) | ||
def test_invalid_label_value(self, name): | ||
assert not gcp_resources.is_valid_label_value(name) | ||
|
||
@pytest.mark.parametrize("name", ["", "a", "---", "some-lable-with-dashes-123"]) | ||
def test_valid_label_value(self, name): | ||
assert gcp_resources.is_valid_label_value(name) |