Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass integration tests #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
name: Bug report
about: Create a report to help us improve

---

### Environment

* Elixir & Erlang/OTP versions (`elixir --version`):
* Operating system:
- Elixir & Erlang/OTP versions (`elixir --version`):
- Operating system:

### Current behavior

Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Prettier
run: npm install --global prettier
- name: Run Prettier
run: prettier --check --no-error-on-unmatched-pattern "**/*.{json,md,yml,yaml}"
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.14.3"
otp-version: "24.3"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
elixir 1.11.3
elixir 1.14.3
erlang 25.3
2 changes: 1 addition & 1 deletion lib/frame/continuation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Continuation do

defstruct [:header_block_fragment, :stream_id, end_headers: false]

use Bitwise
import Bitwise

@type t :: %__MODULE__{
end_headers: boolean,
Expand Down
2 changes: 1 addition & 1 deletion lib/frame/data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Data do

defstruct [:stream_id, :data, end_stream: false]

use Bitwise
import Bitwise

alias Kadabra.Frame

Expand Down
2 changes: 1 addition & 1 deletion lib/frame/headers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Kadabra.Frame.Headers do
weight: non_neg_integer
}

use Bitwise
import Bitwise

alias Kadabra.Frame

Expand Down
2 changes: 1 addition & 1 deletion lib/frame/ping.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Ping do

defstruct [:data, stream_id: 0, ack: false]

use Bitwise
import Bitwise

alias Kadabra.Frame

Expand Down
2 changes: 1 addition & 1 deletion lib/frame/push_promise.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Kadabra.Frame.PushPromise do
header_block_fragment: nil,
stream_id: nil

use Bitwise
import Bitwise

alias Kadabra.Frame

Expand Down
2 changes: 1 addition & 1 deletion lib/frame/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Settings do

defstruct [:settings, ack: false]

use Bitwise
import Bitwise

alias Kadabra.Connection

Expand Down
32 changes: 16 additions & 16 deletions lib/kadabra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Kadabra do

## Usage

{:ok, pid} = Kadabra.open("https://http2.golang.org")
{:ok, pid} = Kadabra.open("https://http2.codedge.dev")
Kadabra.get(pid, "/")
receive do
{:end_stream, %Kadabra.Stream.Response{} = stream} ->
Expand All @@ -32,7 +32,7 @@ defmodule Kadabra do

## Making Requests Manually

{:ok, pid} = Kadabra.open("https://http2.golang.org")
{:ok, pid} = Kadabra.open("https://http2.codedge.dev")

path = "/ECHO" # Route echoes PUT body in uppercase
body = "sample echo request"
Expand Down Expand Up @@ -97,11 +97,11 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open("http://http2.golang.org")
iex> {:ok, pid} = Kadabra.open("http://http2.codedge.dev")
iex> is_pid(pid)
true

iex> {:ok, pid} = Kadabra.open("https://http2.golang.org")
iex> {:ok, pid} = Kadabra.open("https://http2.codedge.dev")
iex> is_pid(pid)
true
"""
Expand All @@ -127,7 +127,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open("https://http2.golang.org")
iex> {:ok, pid} = Kadabra.open("https://http2.codedge.dev")
iex> Kadabra.close(pid)
iex> receive do
...> {:closed, _pid} -> "connection closed!"
Expand All @@ -144,7 +144,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.ping(pid)
iex> receive do
...> {:pong, _pid} -> "got pong!"
Expand All @@ -161,7 +161,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> path = "/ECHO" # Route echoes PUT body in uppercase
iex> body = "sample echo request"
iex> headers = [
Expand Down Expand Up @@ -195,14 +195,14 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> Kadabra.head(pid, "/reqinfo")
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.get(pid, "/")
:ok
iex> response = receive do
...> {:end_stream, response} -> response
...> end
iex> {response.id, response.status, response.body}
{1, 200, ""}
{1, 200, "OK"}
"""
@spec get(pid, String.t(), Keyword.t()) :: no_return
def get(pid, path, opts \\ []) do
Expand All @@ -214,7 +214,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.head(pid, "/")
:ok
iex> response = receive do
Expand All @@ -233,7 +233,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.post(pid, "/", body: "test=123")
:ok
iex> response = receive do
Expand All @@ -252,16 +252,16 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> Kadabra.put(pid, "/crc32", body: "test")
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.put(pid, "/ECHO", body: "example")
:ok
iex> stream = receive do
...> {:end_stream, stream} -> stream
...> end
iex> stream.status
200
iex> stream.body
"bytes=4, CRC32=d87f7e0c"
"EXAMPLE"
"""
@spec put(pid, String.t(), Keyword.t()) :: no_return
def put(pid, path, opts \\ []) do
Expand All @@ -273,7 +273,7 @@ defmodule Kadabra do

## Examples

iex> {:ok, pid} = Kadabra.open('https://http2.golang.org')
iex> {:ok, pid} = Kadabra.open('https://http2.codedge.dev')
iex> Kadabra.delete(pid, "/")
:ok
iex> stream = receive do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule Kadabra.Mixfile do
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:excoveralls, "~> 0.7", only: :test, runtime: false},
{:hpack, "~> 0.2.3", hex: :hpack_erl}
{:hpack, "~> 0.3.0", hex: :hpack_erl}
]
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"gen_stage": {:hex, :gen_stage, "0.13.1", "edff5bca9cab22c5d03a834062515e6a1aeeb7665fb44eddae086252e39c4378", [:mix], [], "hexpm"},
"hackney": {:hex, :hackney, "1.17.0", "717ea195fd2f898d9fe9f1ce0afcc2621a41ecfe137fae57e7fe6e9484b9aa99", [:rebar3], [{:certifi, "~>2.5", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "64c22225f1ea8855f584720c0e5b3cd14095703af1c9fbc845ba042811dc671c"},
"hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"},
"hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"inch_ex": {:hex, :inch_ex, "0.5.6", "418357418a553baa6d04eccd1b44171936817db61f4c0840112b420b8e378e67", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
Expand Down
2 changes: 1 addition & 1 deletion test/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Kadabra.ConnectionTest do
use ExUnit.Case

test "closes active streams on socket close" do
uri = 'https://http2.golang.org'
uri = 'https://http2.codedge.dev'
{:ok, pid} = Kadabra.open(uri)

ref = Process.monitor(pid)
Expand Down
Loading