From e4caab20e1e04ae6b52cbcf22f97aee5edfbd906 Mon Sep 17 00:00:00 2001 From: josh <josh@elixxir.io> Date: Wed, 25 May 2022 16:02:31 -0700 Subject: [PATCH] Test clean up --- api/params_test.go | 2 ++ cmix/params_test.go | 4 ++- connect/params_test.go | 49 ++++++++++++++++++++++++++++++++++++ fileTransfer2/params_test.go | 4 ++- 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 connect/params_test.go diff --git a/api/params_test.go b/api/params_test.go index 82de1d017..35bf61d8f 100644 --- a/api/params_test.go +++ b/api/params_test.go @@ -40,6 +40,8 @@ func TestParams_MarshalUnmarshal(t *testing.T) { t.Fatalf("Marshal error: %v", err) } + t.Logf("%s", string(data2)) + // Check that they match (it is done this way to avoid // false failures with the reflect.DeepEqual function and // pointers) diff --git a/cmix/params_test.go b/cmix/params_test.go index 3a3a2a37e..90ece9d5f 100644 --- a/cmix/params_test.go +++ b/cmix/params_test.go @@ -18,7 +18,7 @@ import ( // Tests that no data is lost when marshaling and // unmarshaling the Params object. -func TestParams_MarshalJSON(t *testing.T) { +func TestParams_MarshalUnmarshal(t *testing.T) { // Construct a set of params p := GetDefaultParams() @@ -43,6 +43,8 @@ func TestParams_MarshalJSON(t *testing.T) { t.Fatalf("Marshal error: %v", err) } + t.Logf("%s", string(data2)) + // Check that they match (it is done this way to avoid // false failures with the reflect.DeepEqual function and // pointers) diff --git a/connect/params_test.go b/connect/params_test.go new file mode 100644 index 000000000..5501ad551 --- /dev/null +++ b/connect/params_test.go @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 xx network SEZC // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file // +//////////////////////////////////////////////////////////////////////////////// + +package connect + +import ( + "bytes" + "encoding/json" + "testing" +) + +func TestParams_MarshalUnmarshal(t *testing.T) { + // Construct a set of params + p := GetDefaultParams() + + // Marshal the params + data, err := json.Marshal(&p) + if err != nil { + t.Fatalf("Marshal error: %v", err) + } + + t.Logf("%s", string(data)) + + // Unmarshal the params object + received := Params{} + err = json.Unmarshal(data, &received) + if err != nil { + t.Fatalf("Unmarshal error: %v", err) + } + + // Re-marshal this params object + data2, err := json.Marshal(received) + if err != nil { + t.Fatalf("Marshal error: %v", err) + } + + t.Logf("%s", string(data2)) + + // Check that they match (it is done this way to avoid + // false failures with the reflect.DeepEqual function and + // pointers) + if !bytes.Equal(data, data2) { + t.Fatalf("Data was lost in marshal/unmarshal.") + } +} diff --git a/fileTransfer2/params_test.go b/fileTransfer2/params_test.go index 25fbdea22..8bbeb942b 100644 --- a/fileTransfer2/params_test.go +++ b/fileTransfer2/params_test.go @@ -17,7 +17,7 @@ import ( // Tests that no data is lost when marshaling and // unmarshaling the Params object. -func TestParams_MarshalJSON(t *testing.T) { +func TestParams_MarshalUnmarshal(t *testing.T) { // Construct a set of params p := DefaultParams() @@ -42,6 +42,8 @@ func TestParams_MarshalJSON(t *testing.T) { t.Fatalf("Marshal error: %v", err) } + t.Logf("%s", string(data2)) + // Check that they match (it is done this way to avoid // false failures with the reflect.DeepEqual function and // pointers) -- GitLab