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

chore: Avoids usage of github.com/go-test/deep (use reflect.DeepEqual instead) #2427

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,7 +5,6 @@ go 1.22
require (
github.com/andygrunwald/go-jira/v2 v2.0.0-20240116150243-50d59fe116d6
github.com/aws/aws-sdk-go v1.54.17
github.com/go-test/deep v1.1.1
github.com/hashicorp/go-changelog v0.0.0-20240318095659-4d68c58a6e7f
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-version v1.7.0
Expand Down
10 changes: 5 additions & 5 deletions internal/common/conversion/encode_state_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package conversion_test

import (
"reflect"
"testing"

"github.com/go-test/deep"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
)

Expand All @@ -16,8 +16,8 @@ func TestEncodeDecodeID(t *testing.T) {

got := conversion.DecodeStateID(conversion.EncodeStateID(expected))

if diff := deep.Equal(expected, got); diff != nil {
t.Fatalf("Bad testEncodeDecodeID return \n got = %#v\nwant = %#v \ndiff = %#v", got, expected, diff)
if !reflect.DeepEqual(expected, got) {
t.Fatalf("Bad testEncodeDecodeID return \n got = %#v\nwant = %#v", got, expected)
}
}

Expand All @@ -28,7 +28,7 @@ func TestDecodeID(t *testing.T) {
got := conversion.DecodeStateID(expected)
got2 := conversion.DecodeStateID(expected2)

if diff := deep.Equal(got, got2); diff != nil {
t.Fatalf("Bad TestDecodeID return \n got = %#v\nwant = %#v \ndiff = %#v", got, got2, diff)
if !reflect.DeepEqual(got, got2) {
t.Fatalf("Bad TestDecodeID return \n got = %#v\nwant = %#v", got, got2)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cloudbackupsnapshot_test

import (
"reflect"
"testing"

"github.com/go-test/deep"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshot"
"go.mongodb.org/atlas-sdk/v20240530002/admin"
)
Expand All @@ -20,8 +20,8 @@ func TestSplitSnapshotImportID(t *testing.T) {
SnapshotId: "5cf5a45a9ccf6400e60981b7",
}

if diff := deep.Equal(expected, got); diff != nil {
t.Errorf("Bad splitSnapshotImportID return \n got = %#v\nwant = %#v \ndiff = %#v", expected, *got, diff)
if !reflect.DeepEqual(expected, got) {
t.Errorf("Bad splitSnapshotImportID return \n got = %#v\nwant = %#v", expected, *got)
}

if _, err := cloudbackupsnapshot.SplitSnapshotImportID("5cf5a45a9ccf6400e60981b6projectname-environment-mongo-global-cluster5cf5a45a9ccf6400e60981b7"); err == nil {
Expand Down
8 changes: 3 additions & 5 deletions internal/service/eventtrigger/resource_event_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"fmt"
"log"
"net/http"
"reflect"
"strings"

"github.com/go-test/deep"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -118,8 +118,7 @@ func Resource() *schema.Resource {
log.Printf("[ERROR] json.Unmarshal %v", err)
return false
}
if diff := deep.Equal(&j, &j2); diff != nil {
log.Printf("[DEBUG] deep equal not passed: %v", diff)
if !reflect.DeepEqual(&j, &j2) {
return false
}

Expand All @@ -140,8 +139,7 @@ func Resource() *schema.Resource {
log.Printf("[ERROR] json.Unmarshal %v", err)
return false
}
if diff := deep.Equal(&j, &j2); diff != nil {
log.Printf("[DEBUG] deep equal not passed: %v", diff)
if !reflect.DeepEqual(&j, &j2) {
return false
}

Expand Down
5 changes: 2 additions & 3 deletions internal/service/searchindex/model_search_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"context"
"encoding/json"
"log"
"reflect"
"strconv"

"github.com/go-test/deep"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -131,8 +131,7 @@ func diffSuppressJSON(k, old, newStr string, d *schema.ResourceData) bool {
if err := json.Unmarshal([]byte(newStr), &j2); err != nil {
log.Printf("[ERROR] cannot unmarshal new search index analyzer json %v", err)
}
if diff := deep.Equal(&j, &j2); diff != nil {
log.Printf("[DEBUG] deep equal not passed: %v", diff)
if !reflect.DeepEqual(&j, &j2) {
return false
}

Expand Down