-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from fromanirh/json-marshal-unmarshal
topology: memory: allow encode/decode cycle (#283)
- Loading branch information
Showing
5 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
// | ||
|
||
package memory_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/jaypipes/ghw/pkg/memory" | ||
"github.com/jaypipes/ghw/pkg/option" | ||
) | ||
|
||
// we have this test in memory_linux_test.go (and not in memory_test.go) because `mem.load.Info` is implemented | ||
// only on linux; so having it in the platform-independent tests would lead to false negatives. | ||
func TestMemoryMarshalUnmarshal(t *testing.T) { | ||
data, err := memory.New(option.WithNullAlerter()) | ||
if err != nil { | ||
t.Fatalf("Expected no error creating memory.Info, but got %v", err) | ||
} | ||
|
||
jdata, err := json.Marshal(data) | ||
if err != nil { | ||
t.Fatalf("Expected no error marshaling memory.Info, but got %v", err) | ||
} | ||
|
||
var topo *memory.Info | ||
|
||
err = json.Unmarshal(jdata, &topo) | ||
if err != nil { | ||
t.Fatalf("Expected no error unmarshaling memory.Info, but got %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters