Beispiel #1
0
def test_multiple_long_form_bases(create_config):
    tmp_path = create_config("""
        type: charm
        bases:
          - build-on:
              - name: test-build-name-1
                channel: test-build-channel-1
            run-on:
              - name: test-run-name-1
                channel: test-run-channel-1
                architectures: [amd64, arm64]
          - build-on:
              - name: test-build-name-2
                channel: test-build-channel-2
            run-on:
              - name: test-run-name-2
                channel: test-run-channel-2
                architectures: [amd64, arm64]
    """)

    config = load(tmp_path)
    assert config.bases == [
        BasesConfiguration(
            **{
                "build-on": [
                    Base(
                        name="test-build-name-1",
                        channel="test-build-channel-1",
                        architectures=[get_host_architecture()],
                    ),
                ],
                "run-on": [
                    Base(
                        name="test-run-name-1",
                        channel="test-run-channel-1",
                        architectures=["amd64", "arm64"],
                    ),
                ],
            }),
        BasesConfiguration(
            **{
                "build-on": [
                    Base(
                        name="test-build-name-2",
                        channel="test-build-channel-2",
                        architectures=[get_host_architecture()],
                    ),
                ],
                "run-on": [
                    Base(
                        name="test-run-name-2",
                        channel="test-run-channel-2",
                        architectures=["amd64", "arm64"],
                    ),
                ],
            }),
    ]
Beispiel #2
0
def test_bases_minimal_short_form(create_config):
    tmp_path = create_config("""
        type: charm
        bases:
          - name: test-name
            channel: test-channel
    """)

    config = load(tmp_path)
    assert config.bases == [
        BasesConfiguration(
            **{
                "build-on": [
                    Base(
                        name="test-name",
                        channel="test-channel",
                        architectures=[get_host_architecture()],
                    ),
                ],
                "run-on": [
                    Base(
                        name="test-name",
                        channel="test-channel",
                        architectures=[get_host_architecture()],
                    ),
                ],
            })
    ]
Beispiel #3
0
def test_no_bases_defaults_to_ubuntu_20_04_with_dn03(emitter, create_config,
                                                     tmp_path):
    create_config("""
        type: charm
    """)

    config = load(tmp_path)

    assert config.bases == [
        BasesConfiguration(
            **{
                "build-on": [Base(name="ubuntu", channel="20.04")],
                "run-on": [Base(name="ubuntu", channel="20.04")],
            })
    ]
    emitter.assert_message("DEPRECATED: Bases configuration is now required.",
                           intermediate=True)
Beispiel #4
0
def test_no_bases_defaults_to_ubuntu_20_04_with_dn03(caplog, create_config,
                                                     tmp_path):
    caplog.set_level(logging.WARNING, logger="charmcraft")
    create_config("""
        type: charm
    """)

    config = load(tmp_path)

    assert config.bases == [
        BasesConfiguration(
            **{
                "build-on": [Base(name="ubuntu", channel="20.04")],
                "run-on": [Base(name="ubuntu", channel="20.04")],
            })
    ]
    assert "DEPRECATED: Bases configuration is now required." in [
        rec.message for rec in caplog.records
    ]