mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-15 00:01:18 +00:00
Merge pull request #144 from tendermint/feature/tags-helper-methods
add 2 helper methods for building KVPair(s)
This commit is contained in:
commit
22b491bb19
19
types/kvpair.go
Normal file
19
types/kvpair.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
// KVPairInt is a helper method to build KV pair with an integer value.
|
||||||
|
func KVPairInt(key string, val int64) *KVPair {
|
||||||
|
return &KVPair{
|
||||||
|
Key: key,
|
||||||
|
ValueInt: val,
|
||||||
|
ValueType: KVPair_INT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// KVPairString is a helper method to build KV pair with a string value.
|
||||||
|
func KVPairString(key, val string) *KVPair {
|
||||||
|
return &KVPair{
|
||||||
|
Key: key,
|
||||||
|
ValueString: val,
|
||||||
|
ValueType: KVPair_STRING,
|
||||||
|
}
|
||||||
|
}
|
15
types/kvpair_test.go
Normal file
15
types/kvpair_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestKVPairInt(t *testing.T) {
|
||||||
|
assert.Equal(t, KVPairInt("a", 1), &KVPair{Key: "a", ValueType: KVPair_INT, ValueInt: 1})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKVPairString(t *testing.T) {
|
||||||
|
assert.Equal(t, KVPairString("a", "b"), &KVPair{Key: "a", ValueType: KVPair_STRING, ValueString: "b"})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user