Skip to content
Merged
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
7 changes: 5 additions & 2 deletions homeassistant/components/prusalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers import issue_registry as ir
from homeassistant.helpers.httpx_client import get_async_client

from .config_flow import ConfigFlow
from .config_flow import PrusaLinkConfigFlow
from .const import DOMAIN
from .coordinator import (
InfoUpdateCoordinator,
Expand Down Expand Up @@ -67,7 +67,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: PrusaLinkConfigEntry) ->

async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Migrate old entry."""
if config_entry.version > ConfigFlow.VERSION:
if (config_entry.version, config_entry.minor_version) > (
PrusaLinkConfigFlow.VERSION,
PrusaLinkConfigFlow.MINOR_VERSION,
):
# This means the user has downgraded from a future version
return False

Expand Down
22 changes: 20 additions & 2 deletions tests/components/prusalink/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from homeassistant.components.prusalink import DOMAIN
from homeassistant.components.prusalink.config_flow import ConfigFlow
from homeassistant.components.prusalink.config_flow import PrusaLinkConfigFlow
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -174,7 +174,25 @@ async def test_migration_fails_on_future_version(
entry = MockConfigEntry(
domain=DOMAIN,
data={},
version=ConfigFlow.VERSION + 1,
version=PrusaLinkConfigFlow.VERSION + 1,
)
entry.add_to_hass(hass)

await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()

assert entry.state is ConfigEntryState.MIGRATION_ERROR


async def test_migration_fails_on_future_minor_version(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test migrating fails on the current version with a higher minor version."""
entry = MockConfigEntry(
domain=DOMAIN,
data={},
version=PrusaLinkConfigFlow.VERSION,
minor_version=PrusaLinkConfigFlow.MINOR_VERSION + 1,
)
entry.add_to_hass(hass)

Expand Down
Loading