github.com/metacurrency/holochain@v0.1.0-alpha-26.0.20200915073418-5c83169c9b5b/entry_agent_test.go (about)

     1  package holochain
     2  
     3  import (
     4    "testing"
     5    . "github.com/smartystreets/goconvey/convey"
     6  )
     7  
     8  func TestAgentEntryToJSON(t *testing.T) {
     9  	a := AgentIdentity("zippy@someemail.com")
    10  	a1, _ := NewAgent(LibP2P, a, MakeTestSeed(""))
    11  	pk, _ := a1.EncodePubKey()
    12  	ae := AgentEntry{
    13  		Identity:  a,
    14  		PublicKey: pk,
    15  	}
    16  
    17  	var j string
    18  	var err error
    19  	Convey("it should convert to JSON", t, func() {
    20  		j, err = ae.ToJSON()
    21  		So(err, ShouldBeNil)
    22  		So(j, ShouldEqual, `{"Identity":"zippy@someemail.com","Revocation":"","PublicKey":"4XTTM4Lf8pAWo6dfra223t4ZK7gjAjFA49VdwrC1wVHQqb8nH"}`)
    23  	})
    24  
    25  	Convey("it should convert from JSON", t, func() {
    26  		ae2, err := AgentEntryFromJSON(j)
    27  		So(err, ShouldBeNil)
    28  		So(ae2, ShouldResemble, ae)
    29  	})
    30  
    31  }