Skip to content

Commit

Permalink
Merge pull request #6 from ipfs-shipyard/jj-more-mod
Browse files Browse the repository at this point in the history
Test within package
  • Loading branch information
Justin Johnson authored Aug 11, 2022
2 parents f93e195 + c7d3990 commit 8b4073e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions redirects_example_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package redirects_test
package redirects

import (
"encoding/json"
"os"

redirects "github.com/ipfs-shipyard/go-ipfs-redirects"
)

func Example() {
h := redirects.Must(redirects.ParseString(`
h := Must(ParseString(`
# Implicit 301 redirects
/home /
/blog/my-post.php /blog/my-post
Expand Down
13 changes: 6 additions & 7 deletions redirects_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package redirects_test
package redirects

import (
"testing"

redirects "github.com/ipfs-shipyard/go-ipfs-redirects"
"github.com/tj/assert"
)

func TestRule_IsProxy(t *testing.T) {
t.Run("without host", func(t *testing.T) {
r := redirects.Rule{
r := Rule{
From: "/blog",
To: "/blog/engineering",
}
Expand All @@ -18,7 +17,7 @@ func TestRule_IsProxy(t *testing.T) {
})

t.Run("with host", func(t *testing.T) {
r := redirects.Rule{
r := Rule{
From: "/blog",
To: "https://blog.apex.sh",
}
Expand All @@ -29,7 +28,7 @@ func TestRule_IsProxy(t *testing.T) {

func TestRule_IsRewrite(t *testing.T) {
t.Run("with 3xx", func(t *testing.T) {
r := redirects.Rule{
r := Rule{
From: "/blog",
To: "/blog/engineering",
Status: 302,
Expand All @@ -39,7 +38,7 @@ func TestRule_IsRewrite(t *testing.T) {
})

t.Run("with 200", func(t *testing.T) {
r := redirects.Rule{
r := Rule{
From: "/blog",
To: "/blog/engineering",
Status: 200,
Expand All @@ -49,7 +48,7 @@ func TestRule_IsRewrite(t *testing.T) {
})

t.Run("with 0", func(t *testing.T) {
r := redirects.Rule{
r := Rule{
From: "/blog",
To: "/blog/engineering",
}
Expand Down

0 comments on commit 8b4073e

Please sign in to comment.