Skip to content

Commit 765d560

Browse files
Migrate username (#9)
1 parent d344268 commit 765d560

File tree

8 files changed

+53
-47
lines changed

8 files changed

+53
-47
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
nix --store ${{ env.CI_NIX_STORE }} \
3333
develop ${{ env.CI_NIX_FLAKE }} --command \
34-
go test -v -cover -race ./...
34+
go test -v -short -cover -race ./...
3535
lint:
3636
runs-on: ubuntu-latest
3737
steps:

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# gostman [![Go Reference](https://pkg.go.dev/badge/github.com/minizilla/gostman.svg)](https://pkg.go.dev/github.com/minizilla/gostman) [![main](https://github.com/minizilla/gostman/actions/workflows/main.yaml/badge.svg)](https://github.com/minizilla/gostman/actions/workflows/main.yaml)
22

3-
[Postman](https://www.postman.com/) like inside [Go](https://golang.org/) testing.
3+
[Postman](https://www.postman.com/) nuances in [Go](https://golang.org/) Test.
44

55
## Install
66

77
Just import gostman to your test package.
88

99
```go
10-
import github.com/injustease/gostman
10+
import github.com/minizilla/gostman
1111
```
1212

1313
## Usage
@@ -100,8 +100,8 @@ import (
100100
"os"
101101
"testing"
102102
103-
"github.com/injustease/is"
104-
"github.com/injustease/gostman"
103+
"github.com/minizilla/gostman"
104+
"github.com/minizilla/testr"
105105
)
106106
107107
func TestMain(m *testing.M) {
@@ -119,15 +119,15 @@ func TestRequest(t *testing.T) {
119119
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
120120
defer res.Body.Close()
121121
122-
is := is.New(t)
123-
is.Equal(res.StatusCode, http.StatusOK)
122+
assert := testr.New(t)
123+
assert.Equal(res.StatusCode, http.StatusOK)
124124
125125
var resp = struct {
126126
Args map[string]string `json:"args"`
127127
}{}
128128
err := json.NewDecoder(res.Body).Decode(&resp)
129-
is.NoError(err)
130-
is.Equal(resp.Args["foo"], "bar")
129+
assert.ErrorIs(err, nil)
130+
assert.Equal(resp.Args["foo"], "bar")
131131
})
132132
})
133133
}

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/postman/postman_test.go

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Package postman_test contains examples of gostman using Postman Echo.
22
// The following list are comparison of hierarchy between gostman and gostman.
33
//
4-
// - The package postman_test is equal to collection in the postman
5-
// - All tests in the form of TextXxx equal to folder in the postman (gostman doesn't support recursive folder)
6-
// - Request itself is running in the subtests
4+
// - The package postman_test is equal to collection in the postman
5+
// - All tests in the form of TextXxx equal to folder in the postman (gostman doesn't support recursive folder)
6+
// - Request itself is running in the subtests
77
package postman_test
88

99
import (
@@ -13,8 +13,8 @@ import (
1313
"os"
1414
"testing"
1515

16-
"github.com/injustease/gostman"
17-
"github.com/injustease/is"
16+
"github.com/minizilla/gostman"
17+
"github.com/minizilla/testr"
1818
)
1919

2020
type postmanResponse struct {
@@ -31,6 +31,10 @@ func TestMain(m *testing.M) {
3131
// TestRequest tests request to postman-echo.
3232
// go test -run Request
3333
func TestRequest(t *testing.T) {
34+
if testing.Short() {
35+
t.SkipNow()
36+
}
37+
3438
gm := gostman.New(t)
3539

3640
// go test -run Request/Params
@@ -43,14 +47,14 @@ func TestRequest(t *testing.T) {
4347
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
4448
defer res.Body.Close()
4549

46-
is := is.New(t)
47-
is.Equal(res.StatusCode, http.StatusOK)
50+
assert := testr.New(t)
51+
assert.Equal(res.StatusCode, http.StatusOK)
4852

4953
var resp postmanResponse
5054
err := json.NewDecoder(res.Body).Decode(&resp)
51-
is.NoError(err)
52-
is.Equal(resp.Args["foo1"], "bar1")
53-
is.Equal(resp.Args["foo2"], "bar2")
55+
assert.ErrorIs(err, nil)
56+
assert.Equal(resp.Args["foo1"], "bar1")
57+
assert.Equal(resp.Args["foo2"], "bar2")
5458
})
5559
})
5660

@@ -64,13 +68,13 @@ func TestRequest(t *testing.T) {
6468
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
6569
defer res.Body.Close()
6670

67-
is := is.New(t)
68-
is.Equal(res.StatusCode, http.StatusOK)
71+
assert := testr.New(t)
72+
assert.Equal(res.StatusCode, http.StatusOK)
6973

7074
var resp postmanResponse
7175
err := json.NewDecoder(res.Body).Decode(&resp)
72-
is.NoError(err)
73-
is.True(resp.Authenticated)
76+
assert.ErrorIs(err, nil)
77+
assert.Equal(resp.Authenticated, true)
7478
})
7579
})
7680

@@ -84,14 +88,14 @@ func TestRequest(t *testing.T) {
8488
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
8589
defer res.Body.Close()
8690

87-
is := is.New(t)
88-
is.Equal(res.StatusCode, http.StatusOK)
91+
assert := testr.New(t)
92+
assert.Equal(res.StatusCode, http.StatusOK)
8993

9094
var resp postmanResponse
9195
err := json.NewDecoder(res.Body).Decode(&resp)
92-
is.NoError(err)
93-
is.Equal(resp.Headers["foo1"], "bar1")
94-
is.Equal(resp.Headers["foo2"], "bar2")
96+
assert.ErrorIs(err, nil)
97+
assert.Equal(resp.Headers["foo1"], "bar1")
98+
assert.Equal(resp.Headers["foo2"], "bar2")
9599
})
96100
})
97101

@@ -104,22 +108,26 @@ func TestRequest(t *testing.T) {
104108
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
105109
defer res.Body.Close()
106110

107-
is := is.New(t)
108-
is.Equal(res.StatusCode, http.StatusOK)
111+
assert := testr.New(t)
112+
assert.Equal(res.StatusCode, http.StatusOK)
109113

110114
var resp postmanResponse
111115
err := json.NewDecoder(res.Body).Decode(&resp)
112-
is.NoError(err)
113-
is.Equal(resp.Data, text)
116+
assert.ErrorIs(err, nil)
117+
assert.Equal(resp.Data, text)
114118
})
115119
})
116120
}
117121

118122
// TestVariable tests request to postman-echo with variable.
119123
//
120-
// Set env: go test -run Variable -env postman
121-
// Set env for the future request too: go test -run Variable -setenv postman
124+
// Set env: go test -run Variable -env postman
125+
// Set env for the future request too: go test -run Variable -setenv postman
122126
func TestVariable(t *testing.T) {
127+
if testing.Short() {
128+
t.SkipNow()
129+
}
130+
123131
gm := gostman.New(t)
124132

125133
// go test -run Variable/Authorization -env postman
@@ -132,13 +140,13 @@ func TestVariable(t *testing.T) {
132140
r.Send(func(t *testing.T, req *http.Request, res *http.Response) {
133141
defer res.Body.Close()
134142

135-
is := is.New(t)
136-
is.Equal(res.StatusCode, http.StatusOK)
143+
assert := testr.New(t)
144+
assert.Equal(res.StatusCode, http.StatusOK)
137145

138146
var resp postmanResponse
139147
err := json.NewDecoder(res.Body).Decode(&resp)
140-
is.NoError(err)
141-
is.True(resp.Authenticated)
148+
assert.ErrorIs(err, nil)
149+
assert.Equal(resp.Authenticated, true)
142150
})
143151
})
144152
}

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
module github.com/injustease/gostman
1+
module github.com/minizilla/gostman
22

33
go 1.17
44

55
require (
6-
github.com/injustease/is v1.5.0
6+
github.com/minizilla/testr v0.2.3
77
github.com/sirupsen/logrus v1.8.1
88
gopkg.in/yaml.v2 v2.4.0
99
)
1010

1111
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
12+
13+
retract v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/injustease/is v1.5.0 h1:lRfe4bt4C6tDqo7PWpSQ6SfeezTjk8UHBEMk8pu/yNg=
4-
github.com/injustease/is v1.5.0/go.mod h1:I2YT3yc64AaWxrl/sYwCmWGy/rEoplE1Pc9Q8ULxg5Q=
3+
github.com/minizilla/testr v0.2.3 h1:Fz6Xo8CBACAFeWygvyRZspt0tF5h6mNJg3duIsEZxgM=
4+
github.com/minizilla/testr v0.2.3/go.mod h1:DdZPGzN8GgQbC2QZ24W/BaWI88xCKUKQ6YLcV/g3hvQ=
55
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
77
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=

gostman.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import (
88
"testing"
99
)
1010

11-
//go:embed VERSION
12-
var gostmanVersion string
13-
1411
// Gostman represents an API development set.
1512
type Gostman struct {
1613
t *testing.T

request_headers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (r *Request) Headers(f func(http.Header)) {
1010
func recomendedHeader() http.Header {
1111
headers := make(http.Header)
1212
headers.Add("Host", "<calculated when request is sent>")
13-
headers.Add("User-Agent", "Gostman/"+gostmanVersion)
13+
headers.Add("User-Agent", "Gostman")
1414
headers.Add("Accept", "*/*")
1515
// headers.Add("Accept-Encoding", "gzip, deflate, br") // TODO
1616
headers.Add("Connection", "keep-alive")

0 commit comments

Comments
 (0)