diff --git a/core/src/create.jl b/core/src/create.jl index a9b64852e..499d42b8f 100644 --- a/core/src/create.jl +++ b/core/src/create.jl @@ -747,7 +747,7 @@ function User(db::DB, config::Config)::User node_ids = NodeID.(node_ids) - user = User( + return User( node_ids, active, demand, @@ -759,8 +759,6 @@ function User(db::DB, config::Config)::User priorities, record, ) - - return user end function Subgrid(db::DB, config::Config, basin::Basin)::Subgrid diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 35632e181..5ca7074d8 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -39,6 +39,12 @@ @test allocated[1] ≈ [0.0, 0.5] @test allocated[2] ≈ [4.0, 0.0] @test allocated[3] ≈ [0.0, 0.0] + + # Test getting and setting user demands + (; user) = p + Ribasim.set_user_demand!(user, NodeID(11), 2, Float64(π)) + @test user.demand[4] ≈ π + @test Ribasim.get_user_demand(user, NodeID(11), 2) ≈ π end @testitem "Allocation objective types" begin