34 lines
642 B
Go
34 lines
642 B
Go
package meta
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestChangedFields(t *testing.T) {
|
|
t.Run("#SetChanged", func(t *testing.T) {
|
|
changedFields := NewChangedFields(3)
|
|
|
|
expectedFieldsMap := map[string]struct{}{
|
|
"a": {},
|
|
"b": {},
|
|
"c": {},
|
|
}
|
|
|
|
changedFields.SetChanged("a", "b", "c", "a")
|
|
|
|
assert.Equal(t, expectedFieldsMap, changedFields.fieldNames)
|
|
})
|
|
|
|
t.Run("#GetFieldsKey", func(t *testing.T) {
|
|
changedFields := NewChangedFields(3)
|
|
changedFields.SetChanged("b", "c", "a")
|
|
expectedKey := "bca"
|
|
|
|
actualKey := changedFields.GetFieldsKey()
|
|
|
|
assert.Equal(t, expectedKey, actualKey)
|
|
})
|
|
}
|