Skip to content

test for Pleroma.Web.CommonAPI.Utils.get_by_id_or_ap_id

Maksim requested to merge parallel588/pleroma:test/web_common_api_utils into develop

added is_flake_id? function. the function checks that id is FlakeID

it fixed the error:

iex(14)> Pleroma.Web.CommonAPI.Utils.get_by_id_or_ap_id("http://example.com/activities/f393ce05-f709-4db5-977f-9bc33c8d1ecc")
** (FunctionClauseError) no function clause matching in Pleroma.FlakeId.decode_base62/2    
    
    The following arguments were given to Pleroma.FlakeId.decode_base62/2:
    
        # 1
        '://example.com/activities/f393ce05-f709-4db5-977f-9bc33c8d1ecc'
    
        # 2
        10462985
    
    Attempted function clauses (showing 4 out of 4):
    
        defp decode_base62([c | cs], acc) when c >= 48 and c <= 57
        defp decode_base62([c | cs], acc) when c >= 65 and c <= 90
        defp decode_base62([c | cs], acc) when c >= 97 and c <= 122
        defp decode_base62([], acc)
    
    (pleroma) lib/pleroma/flake_id.ex:152: Pleroma.FlakeId.decode_base62/2
    (pleroma) lib/pleroma/flake_id.ex:55: Pleroma.FlakeId.from_string/1
    (pleroma) lib/pleroma/flake_id.ex:85: Pleroma.FlakeId.dump/1 
    (ecto) lib/ecto/type.ex:817: Ecto.Type.process_dumpers/3
    (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/repo/queryable.ex:138: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:18: Ecto.Repo.Queryable.all/3
    (ecto) lib/ecto/repo/queryable.ex:67: Ecto.Repo.Queryable.one/3

Merge request reports