package threadsapi import ( "errors" "testing" ) func TestIsPermissionError(t *testing.T) { err := errors.New(`threads api 400: This action requires the threads_basic permission`) if !IsPermissionError(err) { t.Fatal("expected permission error") } if IsPermissionError(errors.New("network timeout")) { t.Fatal("unexpected permission match") } } func TestThreadsUserIDFromToken(t *testing.T) { short := &TokenExchangeResult{UserID: flexString("111")} long := &TokenExchangeResult{UserID: flexString("222")} if got := ThreadsUserIDFromToken(short, long); got != "111" { t.Fatalf("got %q", got) } short.UserID = "" if got := ThreadsUserIDFromToken(short, long); got != "222" { t.Fatalf("got %q", got) } }