This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
summer-utils/utils/key-value-string_test.go

20 lines
841 B
Go

package utils
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestParseKeyValueString(t *testing.T) {
assert.Nil(t, ParseKeyValueString("hello world"))
assert.Equal(t, &KeyValuePair{"hello", "world"}, ParseKeyValueString("hello=world"))
}
func TestParseKeyValueFromStringArray(t *testing.T) {
assert.Equal(t, []KeyValuePair{}, ParseKeyValueFromStringArray([]string{}))
assert.Equal(t, []KeyValuePair{}, ParseKeyValueFromStringArray([]string{"hello world"}))
assert.Equal(t, []KeyValuePair{{"hello", "world"}}, ParseKeyValueFromStringArray([]string{"hello=world"}))
assert.Equal(t, []KeyValuePair{{"hello", "world"}}, ParseKeyValueFromStringArray([]string{"hello=world", "test"}))
assert.Equal(t, []KeyValuePair{{"hello", "world"}, {"test", "1"}}, ParseKeyValueFromStringArray([]string{"hello=world", "test=1"}))
}