886f925b13
As we add file-systems, add them to global state and check the labels are uniqiue. Add a unit test and remove the old global value. Bonus fixup to the length check, and a test for that too. Change-Id: I0f5a96f687c92e000afc9c98a26c49c4b1d3f28d
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import logging
|
|
|
|
import diskimage_builder.block_device.tests.test_config as tc
|
|
|
|
from diskimage_builder.block_device.config import create_graph
|
|
from diskimage_builder.block_device.exception import \
|
|
BlockDeviceSetupException
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class TestMkfs(tc.TestGraphGeneration):
|
|
|
|
def test_duplicate_labels(self):
|
|
|
|
config = self.load_config_file('duplicate_fs_labels.yaml')
|
|
|
|
self.assertRaisesRegex(BlockDeviceSetupException,
|
|
"used more than once",
|
|
create_graph, config,
|
|
self.fake_default_config, {})
|
|
|
|
def test_too_long_labels(self):
|
|
|
|
config = self.load_config_file('too_long_fs_label.yaml')
|
|
|
|
self.assertRaisesRegex(BlockDeviceSetupException,
|
|
"too long for filesystem",
|
|
create_graph, config,
|
|
self.fake_default_config, {})
|