github.com/status-im/status-go@v1.1.0/protocol/communities/request_to_join_test.go (about)

     1  package communities
     2  
     3  import (
     4  	"database/sql"
     5  	"time"
     6  )
     7  
     8  func (s *CommunitySuite) TestRequestToJoin_Empty() {
     9  	// Brand new RequestToJoin should be empty
    10  	rtj := new(RequestToJoin)
    11  	s.True(rtj.Empty(), "The RequestToJoin should be empty")
    12  
    13  	// Add some values, should not be empty
    14  	rtj.State = RequestToJoinStateAccepted
    15  	rtj.Clock = uint64(time.Now().Unix())
    16  	s.False(rtj.Empty(), "The RequestToJoin should not be empty")
    17  
    18  	// Overwrite with a new RequestToJoin, should be empty
    19  	rtj = new(RequestToJoin)
    20  	s.True(rtj.Empty(), "The RequestToJoin should be empty")
    21  
    22  	// Add some empty values, should be empty
    23  	rtj.ChatID = ""
    24  	rtj.ENSName = ""
    25  	rtj.PublicKey = ""
    26  	rtj.Clock = uint64(sql.NullInt64{}.Int64)
    27  	rtj = new(RequestToJoin)
    28  	s.True(rtj.Empty(), "The RequestToJoin should be empty")
    29  
    30  	// Add some not empty values, should be not empty
    31  	rtj.ChatID = "0x1234abcd"
    32  	rtj.ENSName = "@samyoul"
    33  	rtj.PublicKey = "0xfedc0987"
    34  	s.False(rtj.Empty(), "The RequestToJoin should not be empty")
    35  }