|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +# |
| 4 | +# CDDL HEADER START |
| 5 | +# |
| 6 | +# The contents of this file are subject to the terms of the |
| 7 | +# Common Development and Distribution License (the "License"). |
| 8 | +# You may not use this file except in compliance with the License. |
| 9 | +# |
| 10 | +# See LICENSE.txt included in this distribution for the specific |
| 11 | +# language governing permissions and limitations under the License. |
| 12 | +# |
| 13 | +# When distributing Covered Code, include this CDDL HEADER in each |
| 14 | +# file and include the License file at LICENSE.txt. |
| 15 | +# If applicable, add the following below this CDDL HEADER, with the |
| 16 | +# fields enclosed by brackets "[]" replaced with your own identifying |
| 17 | +# information: Portions Copyright [yyyy] [name of copyright owner] |
| 18 | +# |
| 19 | +# CDDL HEADER END |
| 20 | +# |
| 21 | + |
| 22 | +# |
| 23 | +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. |
| 24 | +# |
| 25 | + |
| 26 | +import filecmp |
| 27 | +import logging |
| 28 | +import os |
| 29 | +import tempfile |
| 30 | + |
| 31 | +from opengrok_tools.deploy import deploy_war |
| 32 | + |
| 33 | + |
| 34 | +def test_deploy_dirs(): |
| 35 | + logger = logging.getLogger(__name__) |
| 36 | + |
| 37 | + with tempfile.NamedTemporaryFile(suffix=".war", delete=False) as source_war_fp: |
| 38 | + source_war_fp.write(b"foo") |
| 39 | + source_war = source_war_fp.name |
| 40 | + |
| 41 | + with tempfile.TemporaryDirectory() as tmp_dir: |
| 42 | + assert os.path.isfile(source_war) |
| 43 | + target_war = os.path.join(tmp_dir, "foo", "bar", "my.war") |
| 44 | + target_dir = os.path.dirname(target_war) |
| 45 | + deploy_war(logger, source_war, target_war) |
| 46 | + assert os.path.isdir(target_dir) |
| 47 | + assert os.path.isfile(target_war) |
| 48 | + assert filecmp.cmp(source_war, target_war) |
| 49 | + |
| 50 | + os.unlink(source_war) |
0 commit comments