Skip to content

Commit

Permalink
feat: use go-cmp for testing
Browse files Browse the repository at this point in the history
Signed-off-by: juan131 <jariza@vmware.com>
  • Loading branch information
juan131 committed Dec 4, 2023
1 parent 3dc4b99 commit 0662ab0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/go-chi/cors v1.2.1
github.com/go-chi/httprate v0.7.4
github.com/go-chi/render v1.0.3
github.com/google/go-cmp v0.6.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ github.com/go-chi/httprate v0.7.4 h1:a2GIjv8he9LRf3712zxxnRdckQCm7I8y8yQhkJ84V6M
github.com/go-chi/httprate v0.7.4/go.mod h1:6GOYBSwnpra4CQfAKXu8sQZg+nZ0M1g9QnyFvxrAB8A=
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
7 changes: 4 additions & 3 deletions internal/service/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package service

import (
"net/http"
"reflect"
"testing"

"github.com/google/go-cmp/cmp"
)

func Test_loadConfigFromEnv(t *testing.T) {
Expand Down Expand Up @@ -170,7 +171,7 @@ func Test_loadConfigFromEnv(t *testing.T) {
if (err != nil) != test.wantErr {
t.Errorf("LoadConfigFromEnv() error = %v, wantErr %v", err, test.wantErr)
}
if !reflect.DeepEqual(got, test.want) {
if !cmp.Equal(got, test.want, cmp.AllowUnexported(config{})) {
t.Errorf("LoadConfigFromEnv() = %v, want %v", got, test.want)
}
})
Expand Down Expand Up @@ -306,7 +307,7 @@ func TestStructToMapStringInterface(t *testing.T) {
tt.Errorf("StructToMapStringInterface() error = %v, wantErr %v", err, test.wantErr)
return
}
if !reflect.DeepEqual(got, test.want) {
if !cmp.Equal(got, test.want) {
tt.Errorf("StructToMapStringInterface() = %v, want %v", got, test.want)
}
})
Expand Down

0 comments on commit 0662ab0

Please sign in to comment.