Skip to content
Closed
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion src/azure-cli-testsdk/azure/cli/testsdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ def tearDown(self):

def create_random_name(self, prefix, length):
self.test_resources_count += 1
moniker = '{}{:06}'.format(prefix, self.test_resources_count)
# The moniker's length must match the specified `length` argument, otherwise in recordings' response,
# Content-Length header's value won't match the length of the body, causing failure due to the
# azure-core check: https://github.com/Azure/azure-sdk-for-python/pull/20888

# For example, for prefix='vnetwebapp', length=24
replacement_length = length - len(prefix) # 14
moniker_template = '{}{:0' + str(replacement_length) + '}' # '{}{:014}'
moniker = moniker_template.format(prefix, self.test_resources_count) # 'vnetwebapp00000000000002'

if self.in_recording:
name = create_random_name(prefix, length)
Expand Down
Loading