forked from TrueCloudLab/frostfs-api-go
Add tests for EncodeVariables
This commit is contained in:
parent
cf5f6b1192
commit
fc91a5b232
1 changed files with 28 additions and 0 deletions
28
state/service_test.go
Normal file
28
state/service_test.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package state
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"expvar"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEncodeVariables(t *testing.T) {
|
||||||
|
dump := make(map[string]interface{})
|
||||||
|
|
||||||
|
expvar.NewString("test1").Set("test1")
|
||||||
|
expvar.NewString("test2").Set("test2")
|
||||||
|
|
||||||
|
res := EncodeVariables()
|
||||||
|
|
||||||
|
require.NoError(t, json.Unmarshal(res.Variables, &dump))
|
||||||
|
require.NotEmpty(t, dump)
|
||||||
|
|
||||||
|
// dump should contains keys `test1` and `test2`
|
||||||
|
require.Contains(t, dump, "test1")
|
||||||
|
require.Equal(t, "test1", dump["test1"])
|
||||||
|
|
||||||
|
require.Contains(t, dump, "test2")
|
||||||
|
require.Equal(t, "test2", dump["test2"])
|
||||||
|
}
|
Loading…
Reference in a new issue