Skip to content
Merged
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
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/httpmock)](https://github.com/nhatthm/httpmock/releases/latest)
[![Build Status](https://github.com/nhatthm/httpmock/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/httpmock/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/httpmock/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/httpmock)
[![Go Report Card](https://goreportcard.com/badge/github.com/nhatthm/httpmock)](https://goreportcard.com/report/github.com/nhatthm/httpmock)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/nhatthm/httpmock)
[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/httpmock)](https://goreportcard.com/report/go.nhat.io/httpmock)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/httpmock)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

**httpmock** is a mock library implementing [httptest.Server](https://golang.org/pkg/net/http/httptest/#NewServer) to
Expand Down Expand Up @@ -41,7 +41,7 @@ support HTTP behavioral tests.
## Install

```bash
go get github.com/nhatthm/httpmock
go get go.nhat.io/httpmock
```

[<sub><sup>[table of contents]</sup></sub>](#table-of-contents)
Expand Down Expand Up @@ -70,7 +70,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand All @@ -94,7 +94,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down Expand Up @@ -221,7 +221,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down Expand Up @@ -255,7 +255,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down Expand Up @@ -289,7 +289,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand All @@ -310,7 +310,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand All @@ -337,7 +337,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down Expand Up @@ -369,7 +369,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down Expand Up @@ -405,7 +405,7 @@ package main
import (
"testing"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand All @@ -422,7 +422,7 @@ func TestSimple(t *testing.T) {

## Execution Plan

The mocked HTTP server is created with the `github.com/nhatthm/httpmock/planner.Sequence()` by default, and it matches
The mocked HTTP server is created with the `go.nhat.io/httpmock/planner.Sequence()` by default, and it matches
incoming requests sequentially. You can easily change this behavior to match your application execution by implementing
the `planner.Planner` interface.

Expand All @@ -432,7 +432,7 @@ package planner
import (
"net/http"

"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

type Planner interface {
Expand Down Expand Up @@ -467,8 +467,8 @@ import (
"testing"
"time"

"github.com/nhatthm/httpmock"
"github.com/stretchr/testify/assert"
"go.nhat.io/httpmock"
)

func TestSimple(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"github.com/stretchr/testify/mock"

"github.com/nhatthm/httpmock"
"github.com/nhatthm/httpmock/matcher"
plannerMock "github.com/nhatthm/httpmock/mock/planner"
"github.com/nhatthm/httpmock/must"
"go.nhat.io/httpmock"
"go.nhat.io/httpmock/matcher"
plannermock "go.nhat.io/httpmock/mock/planner"
"go.nhat.io/httpmock/must"
)

func ExampleMockServer_simple() {
Expand Down Expand Up @@ -93,7 +93,7 @@ func ExampleMockServer_expectationsWereNotMet() {

func ExampleMockServer_alwaysFailPlanner() {
srv := httpmock.MockServer(func(s *httpmock.Server) {
p := &plannerMock.Planner{}
p := &plannermock.Planner{}

p.On("IsEmpty").Return(false)
p.On("Expect", mock.Anything)
Expand Down
2 changes: 1 addition & 1 deletion format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"sort"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

const indent = " "
Expand Down
2 changes: 1 addition & 1 deletion format/format_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

func TestFormatValueInline(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/format"
"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/format"
"go.nhat.io/httpmock/matcher"
)

func TestExpectedRequest(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion format/helper_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

func TestIsNil(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/nhatthm/httpmock
module go.nhat.io/httpmock

go 1.17

Expand Down
2 changes: 1 addition & 1 deletion helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/nhatthm/httpmock/test"
"go.nhat.io/httpmock/test"
)

// DoRequest calls DoRequestWithTimeout with 1 second timeout.
Expand Down
2 changes: 1 addition & 1 deletion matcher/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"go.nhat.io/matcher/v2"

"github.com/nhatthm/httpmock/value"
"go.nhat.io/httpmock/value"
)

const initActual = "<could not decode>"
Expand Down
4 changes: 2 additions & 2 deletions matcher/body_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"github.com/nhatthm/httpmock/mock/http"
"go.nhat.io/httpmock/matcher"
"go.nhat.io/httpmock/mock/http"
)

func TestBodyMatcher_Match(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion matcher/fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

func TestFn(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion matcher/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

func TestHeaderMatcher_Match(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package httpmock
import (
"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/test"
"go.nhat.io/httpmock/test"
)

// Mocker is a function that applies expectations to the mocked server.
Expand Down
4 changes: 2 additions & 2 deletions mock/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
tMock "github.com/stretchr/testify/mock"

"github.com/nhatthm/httpmock/planner"
"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/planner"
"go.nhat.io/httpmock/request"
)

// Mocker is Planner mocker.
Expand Down
6 changes: 3 additions & 3 deletions mock/planner/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

"github.com/nhatthm/httpmock/mock/http"
"github.com/nhatthm/httpmock/mock/planner"
"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/mock/http"
"go.nhat.io/httpmock/mock/planner"
"go.nhat.io/httpmock/request"
)

func TestPlanner_IsEmpty(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock"
"go.nhat.io/httpmock"
)

type TestingT struct {
Expand Down
2 changes: 1 addition & 1 deletion must/must_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/must"
"go.nhat.io/httpmock/must"
)

func TestNotFail(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions planner/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"net/http"
"strings"

"github.com/nhatthm/httpmock/format"
"github.com/nhatthm/httpmock/request"
"github.com/nhatthm/httpmock/value"
"go.nhat.io/httpmock/format"
"go.nhat.io/httpmock/request"
"go.nhat.io/httpmock/value"
)

// Error represents an error that occurs while matching a request.
Expand Down
2 changes: 1 addition & 1 deletion planner/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package planner
import (
"net/http"

"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

// MatchRequest checks whether a request is matched.
Expand Down
6 changes: 3 additions & 3 deletions planner/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"github.com/nhatthm/httpmock/mock/http"
"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/matcher"
"go.nhat.io/httpmock/mock/http"
"go.nhat.io/httpmock/request"
)

func TestMatchURI(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package planner
import (
"net/http"

"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

// Planner or Request Execution Planner is in charge of selecting the right expectation for a given request.
Expand Down
2 changes: 1 addition & 1 deletion planner/planner_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package planner

import (
"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

func newExpectWithTimes(i int) *request.Request {
Expand Down
2 changes: 1 addition & 1 deletion planner/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"sync"

"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

var _ Planner = (*sequence)(nil)
Expand Down
2 changes: 1 addition & 1 deletion planner/sequence_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/request"
)

func TestNextExpectations(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions planner/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/stretchr/testify/assert"

"github.com/nhatthm/httpmock/matcher"
"github.com/nhatthm/httpmock/mock/http"
"github.com/nhatthm/httpmock/request"
"go.nhat.io/httpmock/matcher"
"go.nhat.io/httpmock/mock/http"
"go.nhat.io/httpmock/request"
)

func TestSequence(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion request/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"net/http"

"github.com/nhatthm/httpmock/matcher"
"go.nhat.io/httpmock/matcher"
)

// Method returns the method of the expectation.
Expand Down
Loading