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

Remove github.com/kr/pretty in favor of assert.EqualValues() #564

Merged
merged 2 commits into from
Dec 4, 2021
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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ require (
github.com/gorilla/securecookie v1.1.1
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/joho/godotenv v1.4.0
github.com/kr/pretty v0.3.0
github.com/lib/pq v1.10.3
github.com/mattn/go-sqlite3 v1.14.9
github.com/moby/moby v20.10.10+incompatible
Expand Down
8 changes: 1 addition & 7 deletions pipeline/frontend/yaml/compiler/params_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package compiler

import (
"reflect"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
)

Expand All @@ -30,9 +28,5 @@ func TestParamsToEnv(t *testing.T) {
}
got := map[string]string{}
assert.NoError(t, paramsToEnv(from, got))

if !reflect.DeepEqual(want, got) {
t.Errorf("Problem converting plugin parameters to environment variables")
pretty.Ldiff(t, want, got)
}
assert.EqualValues(t, want, got, "Problem converting plugin parameters to environment variables")
}
8 changes: 2 additions & 6 deletions pipeline/frontend/yaml/compiler/script_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
)

func TestGenerateScriptPosix(t *testing.T) {
Expand Down Expand Up @@ -43,10 +43,6 @@ go test
script := generateScriptPosix(test.from)
decoded, _ := base64.StdEncoding.DecodeString(script)
got := string(decoded)

if got != test.want {
t.Errorf("Want encoded script for %s", test.from)
pretty.Ldiff(t, got, test.want)
}
assert.EqualValues(t, got, test.want, "Want encoded script for %s", test.from)
}
}
23 changes: 6 additions & 17 deletions pipeline/frontend/yaml/container_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package yaml

import (
"reflect"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"

"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
Expand Down Expand Up @@ -114,12 +113,8 @@ func TestUnmarshalContainer(t *testing.T) {
}
got := Container{}
err := yaml.Unmarshal(containerYaml, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(want, got) {
t.Errorf("problem parsing container")
pretty.Ldiff(t, want, got)
}
assert.NoError(t, err)
assert.EqualValues(t, want, got, "problem parsing container")
}

// TestUnmarshalContainersErr unmarshals a map of containers. The order is
Expand Down Expand Up @@ -153,12 +148,8 @@ func TestUnmarshalContainers(t *testing.T) {
in := []byte(test.from)
got := Containers{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got.Containers) {
t.Errorf("problem parsing containers %q", test.from)
pretty.Ldiff(t, test.want, got.Containers)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got.Containers, "problem parsing containers %q", test.from)
}
}

Expand All @@ -173,8 +164,6 @@ func TestUnmarshalContainersErr(t *testing.T) {
in := []byte(test)
containers := new(Containers)
err := yaml.Unmarshal(in, &containers)
if err == nil {
t.Errorf("wanted error for containers %q", test)
}
assert.Error(t, err, "wanted error for containers %q", test)
}
}
23 changes: 6 additions & 17 deletions pipeline/frontend/yaml/network_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package yaml

import (
"reflect"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -36,12 +35,8 @@ func TestUnmarshalNetwork(t *testing.T) {
in := []byte(test.from)
got := Network{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got) {
t.Errorf("problem parsing network %q", test.from)
pretty.Ldiff(t, test.want, got)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got, "problem parsing network %q", test.from)
}
}

Expand Down Expand Up @@ -83,12 +78,8 @@ func TestUnmarshalNetworks(t *testing.T) {
in := []byte(test.from)
got := Networks{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got.Networks) {
t.Errorf("problem parsing network %q", test.from)
pretty.Ldiff(t, test.want, got.Networks)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got.Networks, "problem parsing network %q", test.from)
}
}

Expand All @@ -101,8 +92,6 @@ func TestUnmarshalNetworkErr(t *testing.T) {
for _, test := range testdata {
in := []byte(test)
err := yaml.Unmarshal(in, new(Networks))
if err == nil {
t.Errorf("wanted error for networks %q", test)
}
assert.Error(t, err, "wanted error for networks %q", test)
}
}
11 changes: 3 additions & 8 deletions pipeline/frontend/yaml/secret_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package yaml

import (
"reflect"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -54,11 +53,7 @@ func TestUnmarshalSecrets(t *testing.T) {
in := []byte(test.from)
got := Secrets{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got.Secrets) {
t.Errorf("problem parsing secrets %q", test.from)
pretty.Ldiff(t, test.want, got.Secrets)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got.Secrets, "problem parsing secrets %q", test.from)
}
}
23 changes: 6 additions & 17 deletions pipeline/frontend/yaml/volume_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package yaml

import (
"reflect"
"testing"

"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -36,12 +35,8 @@ func TestUnmarshalVolume(t *testing.T) {
in := []byte(test.from)
got := Volume{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got) {
t.Errorf("problem parsing volume %q", test.from)
pretty.Ldiff(t, test.want, got)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got, "problem parsing volume %q", test.from)
}
}

Expand Down Expand Up @@ -83,12 +78,8 @@ func TestUnmarshalVolumes(t *testing.T) {
in := []byte(test.from)
got := Volumes{}
err := yaml.Unmarshal(in, &got)
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(test.want, got.Volumes) {
t.Errorf("problem parsing volumes %q", test.from)
pretty.Ldiff(t, test.want, got.Volumes)
}
assert.NoError(t, err)
assert.EqualValues(t, test.want, got.Volumes, "problem parsing volumes %q", test.from)
}
}

Expand All @@ -101,8 +92,6 @@ func TestUnmarshalVolumesErr(t *testing.T) {
for _, test := range testdata {
in := []byte(test)
err := yaml.Unmarshal(in, new(Volumes))
if err == nil {
t.Errorf("wanted error for volumes %q", test)
}
assert.Error(t, err, "wanted error for volumes %q", test)
}
}
4 changes: 0 additions & 4 deletions vendor/github.com/kr/pretty/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/github.com/kr/pretty/License

This file was deleted.

9 changes: 0 additions & 9 deletions vendor/github.com/kr/pretty/Readme

This file was deleted.

Loading