mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-07 05:24:40 +08:00
Group livebook_teams test suite
This commit is contained in:
parent
db11994b3e
commit
104952be6a
9 changed files with 26 additions and 18 deletions
|
@ -20,7 +20,7 @@ defmodule Livebook.Teams.WebSocket do
|
|||
| {:transport_error, String.t()}
|
||||
| {:server_error, String.t()}
|
||||
def connect(headers \\ []) do
|
||||
uri = URI.parse(Livebook.Config.teams_url())
|
||||
uri = URI.parse(Livebook.Config.teams_url() || raise("missing Livebook Teams URL"))
|
||||
{http_scheme, ws_scheme} = parse_scheme(uri)
|
||||
state = %{status: nil, headers: [], body: []}
|
||||
|
||||
|
|
|
@ -1,56 +1,64 @@
|
|||
defmodule Livebook.HubsTest do
|
||||
use Livebook.TeamsIntegrationCase, async: true
|
||||
# This module cannot run async because it craetes
|
||||
# hubs without an associated backend.
|
||||
use Livebook.DataCase
|
||||
|
||||
alias Livebook.Hubs
|
||||
@sample_hub "team-foo-bar-baz"
|
||||
|
||||
setup do
|
||||
on_exit(fn -> Hubs.delete_hub(@sample_hub) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "get_hubs/0 returns a list of persisted hubs" do
|
||||
team = insert_hub(:team, id: "team-baz")
|
||||
team = insert_hub(:team, id: @sample_hub)
|
||||
assert team in Hubs.get_hubs()
|
||||
|
||||
Hubs.delete_hub("team-baz")
|
||||
Hubs.delete_hub(@sample_hub)
|
||||
refute team in Hubs.get_hubs()
|
||||
end
|
||||
|
||||
test "get_metadata/0 returns a list of persisted hubs normalized" do
|
||||
team = insert_hub(:team, id: "team-livebook")
|
||||
team = insert_hub(:team, id: @sample_hub)
|
||||
metadata = Hubs.Provider.to_metadata(team)
|
||||
|
||||
assert metadata in Hubs.get_metadatas()
|
||||
|
||||
Hubs.delete_hub("team-livebook")
|
||||
Hubs.delete_hub(@sample_hub)
|
||||
refute metadata in Hubs.get_metadatas()
|
||||
end
|
||||
|
||||
test "fetch_hub!/1 returns one persisted team" do
|
||||
assert_raise Livebook.Storage.NotFoundError,
|
||||
~s/could not find entry in \"hubs\" with ID "team-exception-foo"/,
|
||||
~s/could not find entry in "hubs" with ID "#{@sample_hub}"/,
|
||||
fn ->
|
||||
Hubs.fetch_hub!("team-exception-foo")
|
||||
Hubs.fetch_hub!(@sample_hub)
|
||||
end
|
||||
|
||||
team = insert_hub(:team, id: "team-exception-foo")
|
||||
team = insert_hub(:team, id: @sample_hub)
|
||||
|
||||
assert Hubs.fetch_hub!("team-exception-foo") == team
|
||||
assert Hubs.fetch_hub!(@sample_hub) == team
|
||||
end
|
||||
|
||||
test "hub_exists?/1" do
|
||||
refute Hubs.hub_exists?("team-bar")
|
||||
insert_hub(:team, id: "team-bar")
|
||||
assert Hubs.hub_exists?("team-bar")
|
||||
refute Hubs.hub_exists?(@sample_hub)
|
||||
insert_hub(:team, id: @sample_hub)
|
||||
assert Hubs.hub_exists?(@sample_hub)
|
||||
end
|
||||
|
||||
test "save_hub/1 persists hub" do
|
||||
team = build(:team, id: "team-foo")
|
||||
team = build(:team, id: @sample_hub)
|
||||
Hubs.save_hub(team)
|
||||
|
||||
assert Hubs.fetch_hub!("team-foo") == team
|
||||
assert Hubs.fetch_hub!(@sample_hub) == team
|
||||
end
|
||||
|
||||
test "save_hub/1 updates hub" do
|
||||
team = insert_hub(:team, id: "team-foo2")
|
||||
team = insert_hub(:team, id: @sample_hub)
|
||||
Hubs.save_hub(%{team | hub_emoji: "🐈"})
|
||||
|
||||
refute Hubs.fetch_hub!("team-foo2") == team
|
||||
assert Hubs.fetch_hub!("team-foo2").hub_emoji == "🐈"
|
||||
refute Hubs.fetch_hub!(@sample_hub) == team
|
||||
assert Hubs.fetch_hub!(@sample_hub).hub_emoji == "🐈"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue