Skip to content

Commit

Permalink
add tests to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saviorand committed May 31, 2024
1 parent aebce67 commit e297009
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/package.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
name: Package and Release
name: Main pipeline

on:
push:
branches:
- main

permissions:
contents: write

jobs:
run-tests:
name: Release package
setup:
name: Setup environment and install dependencies
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install modular
run: |
curl -s https://get.modular.com | sh -
modular auth examples
- name: Install Mojo
run: modular install mojo

- name: Add to PATH
run: echo "/home/runner/.modular/pkg/packages.modular.com_mojo/bin" >> $GITHUB_PATH

- name: Create package
test:
name: Run tests
runs-on: ubuntu-latest
needs: setup
steps:
- name: Run the test suite
run: mojo run_tests.mojo
package:
name: Create package
runs-on: ubuntu-latest
needs: setup
steps:
- name: Run the package command
run: mojo package lightbug_http -o lightbug_http.mojopkg

- name: Upload package to release
uses: svenstaro/upload-release-action@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions lightbug_http/sys/client.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lightbug_http.client import Client
from lightbug_http.http import HTTPRequest, HTTPResponse, encode, split_http_response_string
from lightbug_http.http import HTTPRequest, HTTPResponse, encode, split_http_string
from lightbug_http.header import ResponseHeader
from lightbug_http.sys.net import create_connection
from lightbug_http.io.bytes import Bytes
Expand Down Expand Up @@ -105,10 +105,10 @@ struct MojoClient(Client):
conn.close()

var response_first_line: String
var response_headers: String
var response_headers: List[String]
var response_body: String

response_first_line, response_headers, response_body = split_http_response_string(new_buf)
response_first_line, response_headers, response_body = split_http_string(new_buf)

# Ugly hack for now in case the default buffer is too large and we read additional responses from the server
var newline_in_body = response_body.find("\r\n")
Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/sys/server.mojo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from lightbug_http.server import DefaultConcurrency
from lightbug_http.net import Listener
from lightbug_http.http import HTTPRequest, encode, split_http_request_string
from lightbug_http.http import HTTPRequest, encode, split_http_string
from lightbug_http.uri import URI
from lightbug_http.header import RequestHeader
from lightbug_http.sys.net import SysListener, SysConnection, SysNet
Expand Down
14 changes: 7 additions & 7 deletions tests/test_http.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def test_split_http_string():

assert_equal(request_body, expected_body[c[].key])

# def test_encode_http_request():
# var req = HTTPRequest(
# # uri,
# # buf,
# # header,
# )
# ...
def test_encode_http_request():
var req = HTTPRequest(
# uri,
# buf,
# header,
)
...

# def test_encode_http_response():
# ...
6 changes: 6 additions & 0 deletions tests/test_net.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

def test_net():
test_split_host_port()

def test_split_host_port():
...

0 comments on commit e297009

Please sign in to comment.